From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Use type_identity_t for non-deducible std::atomic_xxx args
Date: Mon, 13 Jun 2022 20:27:55 +0100 [thread overview]
Message-ID: <20220613192755.928442-1-jwakely@redhat.com> (raw)
Tested powerpc64le-linux, pushed to trunk.
-- >8 --
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.
---
libstdc++-v3/include/std/atomic | 4 +++-
libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc | 13 +++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index 1c6acfa36d0..70055b8fa83 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -1244,8 +1244,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
/// @cond undocumented
+ // _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;
/// @endcond
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>());
+}
--
2.34.3
reply other threads:[~2022-06-13 19:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220613192755.928442-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).