[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)

Hubert Tong via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 14:45:12 PDT 2024


================
@@ -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()) {
----------------
hubert-reinterpretcast wrote:

I do not think there is any particular reason why this change is C++23 specific.
The question remains whether the change should be made at all.

If the primary rationale here is to facilitate testing using the Windows header definitions, I suspect the answer is that the Windows definition of NaN is not a C++ constant expression.

@jcranmer-intel's comment (https://github.com/llvm/llvm-project/pull/88978/files#discussion_r1576817678), supports the interpretation that operations that result in NaN from non-qNaN inputs are not valid in a constant expression.

Other than wanting to use the Windows header definitions for the tests here, is there a reason why this change belongs in this PR?

https://github.com/llvm/llvm-project/pull/88978


More information about the llvm-commits mailing list