* [committed] libstdc++: Add std::atomic<shared_ptr>(nullptr_t) constructor (LWG 3661)
@ 2022-04-26 12:24 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-04-26 12:24 UTC (permalink / raw)
To: libstdc++, gcc-patches
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-04-26 12:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26 12:24 [committed] libstdc++: Add std::atomic<shared_ptr>(nullptr_t) constructor (LWG 3661) 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).