[all-commits] [llvm/llvm-project] 2ac3b1: [libc++] Make std::exp(double) and std::expf const...

Muhammad Bassiouni via All-commits all-commits at lists.llvm.org
Fri Sep 18 11:31:38 PDT 2026


  Branch: refs/heads/users/bassiounix/libcxx-constexpr-exp
  Home:   https://github.com/llvm/llvm-project
  Commit: 2ac3b14906c6e166ab696612c1ff5fc4a1b7e097
      https://github.com/llvm/llvm-project/commit/2ac3b14906c6e166ab696612c1ff5fc4a1b7e097
  Author: bassiounix <muhammad.m.bassiouni at gmail.com>
  Date:   2026-09-18 (Fri, 18 Sep 2026)

  Changed paths:
    M libcxx/include/__math/exponential_functions.h
    M libcxx/include/cmath
    M libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp
    A libcxx/test/libcxx/numerics/c.math/constexpr-cxx26-clang.pass.cpp
    A libcxx/test/libcxx/numerics/c.math/constexpr-cxx26-gcc.pass.cpp

  Log Message:
  -----------
  [libc++] Make std::exp(double) and std::expf constexpr, and target C++26

std::exp(double) and std::expf resolved to the C library's exp(double) and
expf(float) through `using ::exp;` and `using ::expf;` in <cmath>. Clang does
not constant-evaluate those spellings, so the constexpr checks for them failed
even with #199808. Import libc++'s own __math overloads instead, and add a
`template <class = int>` __math::expf so that std::expf doesn't clash with the
C library's non-template expf(float) when both are visible in the same scope,
e.g. after `using namespace std;` or `using std::expf;` at global scope.

std::exp is made constexpr by P1383R2, which is a C++26 paper, not by P0533R9
(C++23), so use _LIBCPP_CONSTEXPR_SINCE_CXX26 and move the checks out of the
P0533R9 test into new compile-time-only P1383R2 tests for Clang and GCC. GCC
already folds the C library's expl, hence the differing expectation there.

Co-Authored-By: Claude Fable 5.1 <noreply at anthropic.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list