Repository navigation
test(numerics): build cfenv_test with -frounding-math on GCC - #375
Merged
Merged
Conversation
The hardened presets build at -O2, where GCC on x86-64 expands std::rint inline as the rounded magnitude with the sign copied back; rint(-2.5) under FE_UPWARD gave -3. -frounding-math, GCC's documented flag for code that changes the rounding mode, keeps it correct. The cfenv page's Gotchas record the finding. Related to #371
This was referenced Nov 3, 2026
Closed
Owner
Author
|
Merged into Checked: gcc-16-hardened on linux/amd64 (as CI), Cfenv 9/9; Cfenv 9/9 on GCC 15 and GCC 16 arm64; cfenv.md snippets 5 checked/0 failed on GCC 15, Clang 22 and GCC 16. Not re-run during review. Still owed: the v0.5.0 workflow re-run on dev (#363). |
This was referenced Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cfenv.RoundingModesfailed in the GCC 16 hardened job. That build is -O2 (RelWithDebInfo), and there GCC on x86-64 expandsstd::rintinline as the rounded magnitude with the sign copied back, so a volatile-2.5under FE_UPWARD gives -3.tests/CMakeLists.txtbuildsnumerics/cfenv_test.cppwith-frounding-mathon GCC, which is GCC's documented flag for code that changes the rounding mode. The test's header comment no longer claims an -O0 build.docs/examples/numerics/cfenv.mdGotchas: records the finding and says to build such code with-frounding-mathon GCC.Related
Test plan
gcc-16-hardenedon linux/amd64 (emulated, as CI):Cfenv.*9/9 pass.Cfenv.*on GCC 15 (Debug) and GCC 16 arm64: 9/9.cfenv.md: GCC 15, Clang 22, GCC 16, each 5 checked, 0 failed.