]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add std::atomic<shared_ptr>(nullptr_t) constructor (LWG 3661)
authorJonathan Wakely <jwakely@redhat.com>
Mon, 25 Apr 2022 17:25:07 +0000 (18:25 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 26 Apr 2022 12:22:18 +0000 (13:22 +0100)
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
libstdc++-v3/testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc

index 9e4df7da7f8b03888498b3b45cb9b9335bd39a38..ff86432f0b40398ab450f878d9e14dd09e6d7e8e 100644 (file)
@@ -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))
       { }
index 1f97224bf6aad232640e6701404524b611a50447..a1902745a3ef4ae9452846d472a8a52817493ac1 100644 (file)
@@ -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()