From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Add std::atomic<shared_ptr>(nullptr_t) constructor (LWG 3661)
Date: Tue, 26 Apr 2022 13:24:29 +0100 [thread overview]
Message-ID: <20220426122429.2075326-1-jwakely@redhat.com> (raw)
Tested powerpc64le-linux, pushed to trunk.
-- >8 --
This DR was approved at the February 2022 plenary.
libstdc++-v3/ChangeLog:
* include/bits/shared_ptr_atomic.h (atomic<shared_ptr>): Add
constructor for constant initialization from nullptr_t.
* testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc:
Check for new constructor.
---
libstdc++-v3/include/bits/shared_ptr_atomic.h | 4 ++++
.../testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc | 2 ++
2 files changed, 6 insertions(+)
diff --git a/libstdc++-v3/include/bits/shared_ptr_atomic.h b/libstdc++-v3/include/bits/shared_ptr_atomic.h
index 9e4df7da7f8..ff86432f0b4 100644
--- a/libstdc++-v3/include/bits/shared_ptr_atomic.h
+++ b/libstdc++-v3/include/bits/shared_ptr_atomic.h
@@ -573,6 +573,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr atomic() noexcept = default;
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 3661. constinit atomic<shared_ptr<T>> a(nullptr); should work
+ constexpr atomic(nullptr_t) noexcept : atomic() { }
+
atomic(shared_ptr<_Tp> __r) noexcept
: _M_impl(std::move(__r))
{ }
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc
index 1f97224bf6a..a1902745a3e 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc
@@ -18,6 +18,8 @@
// Check constexpr constructor.
constinit std::atomic<std::shared_ptr<int>> a;
+// LWG 3661. constinit atomic<shared_ptr<T>> a(nullptr); should work
+constinit std::atomic<std::shared_ptr<int>> a2 = nullptr;
void
test_is_lock_free()
--
2.34.1
reply other threads:[~2022-04-26 12:24 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=20220426122429.2075326-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).