[libc-commits] [clang] [libc] [clang] Make __builtin_exp and __builtin_expf constexpr. (PR #199808)
Hubert Tong via libc-commits
libc-commits at lists.llvm.org
Fri Jun 19 15:00:15 PDT 2026
================
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -fexperimental-new-constant-interpreter %s
+// expected-no-diagnostics
+
+constexpr float InfFloat = __builtin_inff();
+constexpr float NegInfFloat = -__builtin_inff();
+
----------------
hubert-reinterpretcast wrote:
> Any other tests that you would like to be added here?
The consensus for the overall constexpr cmath design in Clang from https://github.com/llvm/llvm-project/pull/158048#issuecomment-3313760151 was that the constant evaluation would fail if `FENV_ACCESS` is ` ON` and the context is not one where the language requires constant evaluation. That way, dynamic rounding modes and the setting of `FE_INEXACT` at run time are observed.
Once the logic is added, there should be a codegen test that expects the call to not be folded when `FENV_ACCESS` is `ON`.
https://github.com/llvm/llvm-project/pull/199808
More information about the libc-commits
mailing list