diff --git a/stl/inc/limits b/stl/inc/limits index cd4bbf056f..b957442428 100644 --- a/stl/inc/limits +++ b/stl/inc/limits @@ -36,7 +36,8 @@ _STL_DISABLE_CLANG_WARNINGS #undef new _STD_BEGIN -_EXPORT_STD enum float_denorm_style { // constants for different IEEE float denormalization styles +// constants for different IEEE float denormalization styles +_EXPORT_STD enum _CXX23_DEPRECATE_DENORM float_denorm_style { denorm_indeterminate = -1, denorm_absent = 0, denorm_present = 1 @@ -51,8 +52,11 @@ _EXPORT_STD enum float_round_style { // constants for different IEEE rounding st }; struct _Num_base { // base for all types, with common defaults - static constexpr float_denorm_style has_denorm = denorm_absent; - static constexpr bool has_denorm_loss = false; + _STL_DISABLE_DEPRECATED_WARNING + _CXX23_DEPRECATE_DENORM static constexpr float_denorm_style has_denorm = denorm_absent; + _CXX23_DEPRECATE_DENORM static constexpr bool has_denorm_loss = false; + _STL_RESTORE_DEPRECATED_WARNING + static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; @@ -134,7 +138,10 @@ struct _Num_int_base : _Num_base { // base for integer types }; struct _Num_float_base : _Num_base { // base for floating-point types - static constexpr float_denorm_style has_denorm = denorm_present; + _STL_DISABLE_DEPRECATED_WARNING + _CXX23_DEPRECATE_DENORM static constexpr float_denorm_style has_denorm = denorm_present; + _STL_RESTORE_DEPRECATED_WARNING + static constexpr bool has_infinity = true; static constexpr bool has_quiet_NaN = true; static constexpr bool has_signaling_NaN = true; diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index b1fc9a6c94..02308dbbfa 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -365,6 +365,7 @@ // _HAS_CXX23 and _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS control: // P1413R3 Deprecate aligned_storage And aligned_union +// P2614R2 Deprecating float_denorm_style, numeric_limits::has_denorm, numeric_limits::has_denorm_loss // Other C++23 deprecation warnings // Parallel Algorithms Notes @@ -1431,7 +1432,18 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect #define _CXX23_DEPRECATE_UNIX_STREAMS #endif // ^^^ warning disabled ^^^ -// next warning number: STL4042 +#if _HAS_CXX23 && !defined(_SILENCE_CXX23_DENORM_DEPRECATION_WARNING) \ + && !defined(_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS) +#define _CXX23_DEPRECATE_DENORM \ + [[deprecated("warning STL4042: " \ + "std::float_denorm_style, std::numeric_limits::has_denorm, and std::numeric_limits::has_denorm_loss " \ + "are deprecated in C++23. You can define _SILENCE_CXX23_DENORM_DEPRECATION_WARNING or " \ + "_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS to suppress this warning.")]] +#else // ^^^ warning enabled / warning disabled vvv +#define _CXX23_DEPRECATE_DENORM +#endif // ^^^ warning disabled ^^^ + +// next warning number: STL4043 // next error number: STL1006 diff --git a/tests/std/tests/Dev11_1074023_constexpr/test.cpp b/tests/std/tests/Dev11_1074023_constexpr/test.cpp index cdd745fd63..58c32ebc3e 100644 --- a/tests/std/tests/Dev11_1074023_constexpr/test.cpp +++ b/tests/std/tests/Dev11_1074023_constexpr/test.cpp @@ -6,6 +6,7 @@ #define _SILENCE_CXX17_IS_LITERAL_TYPE_DEPRECATION_WARNING #define _SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING #define _SILENCE_CXX20_IS_POD_DEPRECATION_WARNING +#define _SILENCE_CXX23_DENORM_DEPRECATION_WARNING #include #include diff --git a/tests/tr1/tests/limits/test.cpp b/tests/tr1/tests/limits/test.cpp index 96bdfa08d8..08e98d7346 100644 --- a/tests/tr1/tests/limits/test.cpp +++ b/tests/tr1/tests/limits/test.cpp @@ -4,6 +4,8 @@ // test #define TEST_NAME "" +#define _SILENCE_CXX23_DENORM_DEPRECATION_WARNING + #include "tdefs.h" #include #include