public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r12-8267] libstdc++: Add std::atomic<shared_ptr>(nullptr_t) constructor (LWG 3661)
Date: Tue, 26 Apr 2022 12:24:07 +0000 (GMT)	[thread overview]
Message-ID: <20220426122407.74FDC3857C41@sourceware.org> (raw)

https://gcc.gnu.org/g:41ccd683f0002d7b5127aafc00dcd59e7837f0ab

commit r12-8267-g41ccd683f0002d7b5127aafc00dcd59e7837f0ab
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Apr 25 18:25:07 2022 +0100

    libstdc++: Add std::atomic<shared_ptr>(nullptr_t) constructor (LWG 3661)
    
    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.

Diff:
---
 libstdc++-v3/include/bits/shared_ptr_atomic.h                         | 4 ++++
 libstdc++-v3/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()


                 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=20220426122407.74FDC3857C41@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@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).