================ @@ -2922,7 +2922,7 @@ static bool handleFloatFloatBinOp(EvalInfo &Info, const BinaryOperator *E, // If during the evaluation of an expression, the result is not // mathematically defined [...], the behavior is undefined. // FIXME: C++ rules require us to not conform to IEEE 754 here. - if (LHS.isNaN()) { + if (!Info.getLangOpts().CPlusPlus23 && LHS.isNaN()) { ---------------- AaronBallman wrote:
I think we're potentially misinterpreting the standard here regarding NANs. CC @jcranmer-intel @hubert-reinterpretcast https://eel.is/c++draft/basic.fundamental#13 is the interesting bit (I think), and I believe it's saying that if the floating-point representation you use has a way to represent a mathematical value then that value is "representable in that type". e.g., if your fp format can support positive/negative infinity, then a positive/negative infinity is considered representable. Note 10 says that more explicitly as: "Since negative and positive infinity are representable in ISO/IEC/IEEE 60559 formats, all real numbers lie within the range of representable values of a floating-point type adhering to ISO/IEC/IEEE 60559." NANs are representable within ISO/IEC 60559 and are a mathematical result of an operation such as zero divided by zero. So I believe NANs are valid in a constant expression. MSVC, Clang, and GCC all agree that they're not, but EDG believes they are: https://godbolt.org/z/cxPcKGvP3 https://github.com/llvm/llvm-project/pull/88978 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits