Skip to content

Suppress C++23 float_denorm_style deprecation warning in numeric_limits<half>#546

Open
cary-ilm wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
cary-ilm:float_denorm_style-warning
Open

Suppress C++23 float_denorm_style deprecation warning in numeric_limits<half>#546
cary-ilm wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
cary-ilm:float_denorm_style-warning

Conversation

@cary-ilm
Copy link
Member

@cary-ilm cary-ilm commented Mar 1, 2026

Part of an effort to get CI building without warnings.

C++23 deprecates std::float_denorm_style and std::denorm_present but does not remove them or provide a replacement; std::numeric_limits still requires has_denorm to be of that type, so we must use it, which leads to a warning:

  src/Imath/half.h:948:22: warning: 'float_denorm_style' is deprecated [-Wdeprecated-declarations]
      static constexpr float_denorm_style has_denorm        = denorm_present;
                       ^

Suppress the warning for this use and only when building in C++23 (or later): wrap the has_denorm declaration in compiler-specific pragmas (GCC/Clang -Wdeprecated-declarations, MSVC 4996) guarded by (__cplusplus >= 202302L) and the compiler macro. Pre-C++23 builds are unchanged and use no pragmas.

Made-with: Cursor

…ts<half>

Part of an effort to get CI building without warnings.

C++23 deprecates std::float_denorm_style and std::denorm_present
but does not remove them or provide a replacement; std::numeric_limits
still requires has_denorm to be of that type, so we must use it, which leads to a warning:

  src/Imath/half.h:948:22: warning: 'float_denorm_style' is deprecated [-Wdeprecated-declarations]
      static constexpr float_denorm_style has_denorm        = denorm_present;
                       ^

Suppress the warning for this use and only when building in C++23 (or
later): wrap the has_denorm declaration in compiler-specific pragmas
(GCC/Clang -Wdeprecated-declarations, MSVC 4996) guarded by
(__cplusplus >= 202302L) and the compiler macro. Pre-C++23 builds are
unchanged and use no pragmas.

Made-with: Cursor
Signed-off-by: Cary Phillips <cary@ilm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant