summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-06-13 16:36:14 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-06-14 20:29:48 +0100
commitd10b3b5c1f61c05b3cf1229d0bd961db3f8ee653 (patch)
tree5036a227fa1f863b7813ccd021ab2b00225e1a94
parentlibstdc++: Rename __null_terminated to avoid collision with Apple SDK (diff)
downloadgcc-d10b3b5c1f61c05b3cf1229d0bd961db3f8ee653.tar.gz
gcc-d10b3b5c1f61c05b3cf1229d0bd961db3f8ee653.tar.bz2
gcc-d10b3b5c1f61c05b3cf1229d0bd961db3f8ee653.tar.xz
libstdc++: Use type_identity_t for non-deducible std::atomic_xxx args
This is LWG 3220 which is about to become Tentatively Ready. libstdc++-v3/ChangeLog: * include/std/atomic (__atomic_val_t): Use __type_identity_t instead of atomic<T>::value_type, as per LWG 3220. * testsuite/29_atomics/atomic/lwg3220.cc: New test. (cherry picked from commit 30cc1b65e4efa1a2c57fec5574fcae7a446b822f)
-rw-r--r--libstdc++-v3/include/std/atomic5
-rw-r--r--libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc13
2 files changed, 16 insertions, 2 deletions
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index d819b6bf41e..cf5d7309334 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -1241,9 +1241,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
1241 atomic_flag_clear(volatile atomic_flag* __a) noexcept 1241 atomic_flag_clear(volatile atomic_flag* __a) noexcept
1242 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); } 1242 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
1243 1243
1244 1244 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1245 // 3220. P0558 broke conforming C++14 uses of atomic shared_ptr
1245 template<typename _Tp> 1246 template<typename _Tp>
1246 using __atomic_val_t = typename atomic<_Tp>::value_type; 1247 using __atomic_val_t = __type_identity_t<_Tp>;
1247 template<typename _Tp> 1248 template<typename _Tp>
1248 using __atomic_diff_t = typename atomic<_Tp>::difference_type; 1249 using __atomic_diff_t = typename atomic<_Tp>::difference_type;
1249 1250
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc b/libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc
new file mode 100644
index 00000000000..d2ff6cf9fe3
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc
@@ -0,0 +1,13 @@
1// { dg-do compile { target c++11 } }
2// DR 3220. P0558 broke conforming C++14 uses of atomic shared_ptr
3
4#include <atomic>
5#include <memory>
6
7struct Abstract { virtual void test() = 0; };
8struct Concrete : Abstract { virtual void test() override {} };
9
10int main() {
11 std::shared_ptr<Abstract> ptr;
12 std::atomic_store<Abstract>(&ptr, std::make_shared<Concrete>());
13}