Compiler warning: using infinity leads to undefined behaviour with some floating-point options
Description
json.hpp:10652:31: warning: use of infinity is undefined behavior due to the currently enabled floating-point options [-Wnan-infinity-disabled]
10652 | ? std::numeric_limits<double>::infinity()
Some floating point compiler options do not agree with the usage of std::numeric_limits
Reproduction steps
Compile with (Apple) Clang with -ffast-math enabled
Expected vs. actual results
My expectation would be that json.hpp doesn't trigger -Wnan-infinity-disabled
Minimal code example
Error messages
Compiler and operating system
Apple clang version 17.0.0 (clang-1700.0.13.5) Target: arm64-apple-darwin24.5.0
Library version
3.12.0
Validation
- [ ] The bug also occurs if the latest version from the
developbranch is used. - [ ] I can successfully compile and run the unit tests.
My expectation would be that json.hpp doesn't trigger
-Wnan-infinity-disabled
I'm not sure that's a reasonable expectation. Asking a library that deals with floating point numbers to never use nan or infinity seems rather odd.
Some useful information: https://simonbyrne.github.io/notes/fastmath/
Thanks @gregmarr. I am also confused. Should the library suppress warnings about features disabled by a client program?
This issue has been marked as stale because it has been open for 90 days without activity. If this issue is still relevant, please add a comment or remove the "stale" label. Otherwise, it will be closed in 10 days. Thank you for helping us prioritize our work!
This issue has been closed after being marked as stale for 10 days without any further activity. If this was done in error or the issue is still relevant, please feel free to reopen it or create a new issue. We appreciate your understanding and contributions.