[gcc r15-1118] libstdc++: Add missing constexpr to __atomic_impl::__clear_padding
Jonathan Wakely
redi@gcc.gnu.org
Sat Jun 8 14:53:39 GMT 2024
https://gcc.gnu.org/g:ae91b5dd14920ff9671db8ff80c0d763d25f977f
commit r15-1118-gae91b5dd14920ff9671db8ff80c0d763d25f977f
Author: Deev Patel <dkp10000@gmail.com>
Date: Thu Jun 6 11:53:25 2024 +0100
libstdc++: Add missing constexpr to __atomic_impl::__clear_padding
This is called from the std::atomic<floating-point-type> constructor,
which needs to be usable in constant expressions.
libstdc++-v3/ChangeLog:
* include/bits/atomic_base.h (__atomic_impl::__clear_padding):
Add missing constexpr specifier.
* testsuite/29_atomics/atomic_float/constinit.cc: New test.
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Diff:
---
libstdc++-v3/include/bits/atomic_base.h | 2 +-
libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index 062f1549740..20901b7fc06 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<typename _Tp>
- _GLIBCXX_ALWAYS_INLINE _Tp*
+ _GLIBCXX_ALWAYS_INLINE _GLIBCXX14_CONSTEXPR _Tp*
__clear_padding(_Tp& __val) noexcept
{
auto* __ptr = std::__addressof(__val);
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc b/libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc
new file mode 100644
index 00000000000..6b3f4f76b4c
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc
@@ -0,0 +1,3 @@
+// { dg-do compile { target c++20 } }
+#include <atomic>
+constinit std::atomic<float> a(0.0f);
More information about the Gcc-cvs
mailing list