================
@@ -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:

The plot thickens, this may be a case where it's defined in C but C++ doesn't 
bother defining much of anything about floating-point and thus it is UB: 
https://github.com/cplusplus/draft/issues/5407

That said, https://eel.is/c++draft/basic.fundamental#12.sentence-8 seems to 
make this implementation-defined and it would be reasonable for us to define 
C++ as following the C semantics in situations where C++ is silent on the 
behavior.

C is more clear on this point. C23 5.2.5.3.3p8: Floating types shall be able to 
represent signed zeros or an unsigned zero and all normalized floating point 
numbers. In addition, floating types may be able to contain other kinds of 
floating-point numbers, such as subnormal floating-point numbers and 
unnormalized floating-point numbers, and
values that are not floating-point numbers, such as NaNs and (signed and 
unsigned) infinities.

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

Reply via email to