Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement P2614R2 Deprecating float_denorm_style, numeric_limits::has_denorm, numeric_limits::has_denorm_loss #3482

Merged
merged 20 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions stl/inc/limits
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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
barcharcraz marked this conversation as resolved.
Show resolved Hide resolved

static constexpr bool has_infinity = true;
static constexpr bool has_quiet_NaN = true;
static constexpr bool has_signaling_NaN = true;
Expand Down
14 changes: 13 additions & 1 deletion stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/std/tests/Dev11_1074023_constexpr/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <algorithm>
#include <array>
Expand Down
2 changes: 2 additions & 0 deletions tests/tr1/tests/limits/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// test <limits>
#define TEST_NAME "<limits>"

#define _SILENCE_CXX23_DENORM_DEPRECATION_WARNING

#include "tdefs.h"
#include <float.h>
#include <limits.h>
Expand Down