Things like std::atomic are currently unable to be created in a constexpr context with clang 18 and c++20. Example compilation error ``` external/com_google_tcmalloc/tcmalloc/parameters.cc:223:17: error: variable does not have a constant initializer 223 | Parameters::peak_sampling_heap_growth_fraction_(1.1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ external/com_google_tcmalloc/tcmalloc/parameters.cc:222:1: note: required by 'constinit' specifier here 222 | ABSL_CONST_INIT std::atomic | ^~~~~~~~~~~~~~~ external/com_google_absl/absl/base/attributes.h:743:25: note: expanded from macro 'ABSL_CONST_INIT' 743 | #define ABSL_CONST_INIT constinit | ^~~~~~~~~ external/local_config_clang/crosstool/extra_tools/lib/gcc/x86_64-linux-gnu/14.1.0/../../../../include/c++/14.1.0/bits/atomic_base.h:1286:9: note: non-constexpr function '__clear_padding' cannot be used in a constant expression 1286 | { __atomic_impl::__clear_padding(_M_fp); } | ^ external/local_config_clang/crosstool/extra_tools/lib/gcc/x86_64-linux-gnu/14.1.0/../../../../include/c++/14.1.0/atomic:1644:38: note: in call to '__atomic_float(1.100000e+00)' 1644 | atomic(double __fp) noexcept : __atomic_float(__fp) ``` This patch adds the necessary constexpr specifier. - Deev Patel diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index 062f1549740..5e89f66f620 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -968,7 +968,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template - _GLIBCXX_ALWAYS_INLINE _Tp* + constexpr _GLIBCXX_ALWAYS_INLINE _Tp* __clear_padding(_Tp& __val) noexcept { auto* __ptr = std::__addressof(__val);