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

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 24 19:04:34 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:

> Do we want to do the same for C++23? If not what's exactly an "unspecified" value?

It means that `INT_MAX` and `INT_MIN` is fine (based on the wording). The committee discussion had already decided that the constexpr evaluation need not match the target's runtime in terms of implementation-defined behavior with respect to:
- what cases are errors, and
- how non-error cases of NaNs and infinities, etc. are handled.

Instead, C's Annex F was to specify the behaviour; however, that C's Annex F did not fully specify the result (as in the case in question) was not discussed.


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


More information about the cfe-commits mailing list