Open
Description
Consider:
constexpr float inf = 1.0f / 0.0f;
constexpr float nan = 0.0f / 0.0f;
Clang currently rejects these, while GCC accepts: https://godbolt.org/z/oG4sP9TMc
I believe Clang is wrong to reject, per C23 6.5.6p6-7 for division, 5.2.5.3.3p19 for infinity being a valid value, 6.7.2p5-6 for constexpr requirements, and 6.6p4 for constant initialization requirements.
Note, __builtin_inff()
and __builtin_nan()
both work as an initializer for a constexpr variable.