[libcxx][test] `signaling_NaN()` should not be used in `constexpr <cmath>` tests
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
libcxx's initial tests for `constexpr ` are exercising signaling NaNs, which MSVC's implementation rejects. I believe that this test code is bogus, and that use of signaling NaNs should be removed.
# Standardese
[N5054](https://isocpp.org/files/papers/N5054.pdf) \[c.math.fpclass\]/1:
> The classification / comparison functions behave the same as the C macros with the corresponding names defined in the C standard library.
[N3220](https://open-std.org/JTC1/SC22/WG14/www/docs/n3220.pdf) (C23) 7.12.17.1 "The isgreater macro"/2:
> However, unlike `(x) > (y)`, `isgreater(x,y)` does not raise the "invalid" floating-point exception when `x` and `y` are unordered and neither is a signaling NaN.
7.12.17.2 "The isgreaterequal macro"/2:
> However, unlike `(x) >= (y)`, `isgreaterequal(x,y)` does not raise the "invalid" floating-point exception when `x` and `y` are unordered and neither is a signaling NaN.
7.12.17.4 "The islessequal macro"/2:
> However, unlike `(x) <= (y)`, `islessequal(x,y)` does not raise the "invalid" floating-point exception when `x` and `y` are unordered and neither is a signaling NaN.
7.12.17.6 "The isunordered macro"/2:
> It does not raise the "invalid" floating-point exception when `x` and `y` are unordered and neither is a signaling NaN.
# Bogus test code
https://github.com/llvm/llvm-project/blob/77874a5794a3bb007cda2e6a5ac77e7ce48cf8c4/libcxx/test/std/numerics/c.math/isgreater.pass.cpp#L35
https://github.com/llvm/llvm-project/blob/77874a5794a3bb007cda2e6a5ac77e7ce48cf8c4/libcxx/test/std/numerics/c.math/isgreaterequal.pass.cpp#L34
https://github.com/llvm/llvm-project/blob/77874a5794a3bb007cda2e6a5ac77e7ce48cf8c4/libcxx/test/std/numerics/c.math/islessequal.pass.cpp#L34
https://github.com/llvm/llvm-project/blob/77874a5794a3bb007cda2e6a5ac77e7ce48cf8c4/libcxx/test/std/numerics/c.math/isunordered.pass.cpp#L31
Contributor guide
Research direction
Start with the four cited libcxx tests: isgreater.pass.cpp, isgreaterequal.pass.cpp, islessequal.pass.cpp, and isunordered.pass.cpp, focusing on their signaling_NaN() uses. Run these constexpr tests before and after the change. Done means the tests no longer use signaling NaNs and pass with MSVC and the existing test configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100