[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
Hubert Tong via cfe-commits
cfe-commits at lists.llvm.org
Sat May 18 20:02:45 PDT 2024
hubert-reinterpretcast wrote:
> Some more thought is needed on how to handle the non-`__builtin_`-prefixed cases under non-C++23-or-higher language modes. The specific implications of those functions being non-`constexpr` under said modes (as required, for C++, by https://wg21.link/constexpr.functions) may determine the solution to apply in this PR.
It seems that Clang _does_ care whether or not a function is `constexpr` (outside of an actual attempt to evaluate it during constant evaluation) when it is trying to diagnose the pre-C++23 IFNDR situation of a `constexpr` function that never produces a constant expression: https://godbolt.org/z/hnfqrrrdM
```cpp
extern "C" double fmin(double, double); // expected-note {{declared here}}
constexpr double contrived() { return fmin(0., 0.); }
// expected-error at -1 {{constexpr function never produces a constant expression}}
// expected-note at -2 {{non-constexpr function 'fmin' cannot be used in a constant expression}}
```
Aside: Clang checks the arguments before the function declaration.
https://github.com/llvm/llvm-project/pull/88978
More information about the cfe-commits
mailing list