[clang] [Clang] Add constexpr eval for cmath builtins (PR #194327)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 5 07:03:12 PDT 2026


Serosh-commits wrote:

> I haven't looked at the results for numerical correctness, so far I've just been making sure that expressions are non-constexpr when they produce signals.
> 
> The AST-based constexpr evaluator does such a bad job of producing this behavior that I haven't noted all of its failures; it looks to me that the helper method you expect to cause bailout on exception behavior doesn't actually do that. So for the most part, the comments are focused on the bytecode interpreter, which catches some but not all of the cases.

i too think that  the AST evaluator's `checkFloatingPointResult` is wrong there . It has this early return before chceking 

```cpp
if (Info.InConstantContext)
  return true;
```
which completely skips checking `St` for exceptions which is the only problem i am seeing which i fixed it in my helper 
I actually originally added this exact same early return to my new `CheckFloatResult` helper in `InterpBuiltin.cpp` just to be consistent with the AST evaluator, but thanks to Hubert he pointed  pointed it out(https://github.com/llvm/llvm-project/pull/194327#discussion_r3290705989) that it defeats the whole purpose of the function (we *need* to catch exceptions when evaluating constant expression i think wee can simply just move the hard exception check above that early return in `ExprConstant.cpp` let me know what u think about this ??

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


More information about the cfe-commits mailing list