public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10068] libstdc++: Use type_identity_t for non-deducible std::atomic_xxx args
@ 2022-06-15  8:10 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-06-15  8:10 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:76ff0e644f5ebe39325d587a0bc7363ce89dcc9e

commit r11-10068-g76ff0e644f5ebe39325d587a0bc7363ce89dcc9e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Jun 13 16:36:14 2022 +0100

    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)

Diff:
---
 libstdc++-v3/include/std/atomic                     |  5 +++--
 libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc | 13 +++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index 0d4e3a7396e..22faf82edde 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -1236,9 +1236,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   atomic_flag_clear(volatile atomic_flag* __a) noexcept
   { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
 
-
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 3220. P0558 broke conforming C++14 uses of atomic shared_ptr
   template<typename _Tp>
-    using __atomic_val_t = typename atomic<_Tp>::value_type;
+    using __atomic_val_t = __type_identity_t<_Tp>;
   template<typename _Tp>
     using __atomic_diff_t = typename atomic<_Tp>::difference_type;
 
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 @@
+// { dg-do compile { target c++11 } }
+// DR 3220. P0558 broke conforming C++14 uses of atomic shared_ptr
+
+#include <atomic>
+#include <memory>
+
+struct Abstract { virtual void test() = 0; };
+struct Concrete : Abstract { virtual void test() override {} };
+
+int main() {
+  std::shared_ptr<Abstract> ptr;
+  std::atomic_store<Abstract>(&ptr, std::make_shared<Concrete>());
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-15  8:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15  8:10 [gcc r11-10068] libstdc++: Use type_identity_t for non-deducible std::atomic_xxx args Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).