[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
Tue Apr 23 13:49:17 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:
My understanding of the intended design was that operations producing NaNs from non-NaNs in C++ constexpr cause the expression to not be constant. That said, NaNs are still in play because of `numeric_limits`.
For `frexp` though, I think there being an "unspecified" value stored for the exponent is a problem where the design could use more clarity. I would think that the operation could still be performed, but the "unspecified" value should probably be considered indeterminate.
https://github.com/llvm/llvm-project/pull/88978
More information about the cfe-commits
mailing list