From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 27BCA384147A; Tue, 14 Jun 2022 20:58:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27BCA384147A MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-8480] libstdc++: Use type_identity_t for non-deducible std::atomic_xxx args X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: d1201dbf55a11d391030914985ba6b443e59baa5 X-Git-Newrev: d10b3b5c1f61c05b3cf1229d0bd961db3f8ee653 Message-Id: <20220614205804.27BCA384147A@sourceware.org> Date: Tue, 14 Jun 2022 20:58:04 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2022 20:58:04 -0000 https://gcc.gnu.org/g:d10b3b5c1f61c05b3cf1229d0bd961db3f8ee653 commit r12-8480-gd10b3b5c1f61c05b3cf1229d0bd961db3f8ee653 Author: Jonathan Wakely Date: Mon Jun 13 16:36:14 2022 +0100 libstdc++: Use type_identity_t for non-deducible std::atomic_xxx args 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::value_type, as per LWG 3220. * testsuite/29_atomics/atomic/lwg3220.cc: New test. (cherry picked from commit 30cc1b65e4efa1a2c57fec5574fcae7a446b822f) Diff: --- libstdc++-v3/include/std/atomic | 5 +++-- libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index d819b6bf41e..cf5d7309334 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -1241,9 +1241,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION atomic_flag_clear(volatile atomic_flag* __a) noexcept { atomic_flag_clear_explicit(__a, memory_order_seq_cst); } - + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3220. P0558 broke conforming C++14 uses of atomic shared_ptr template - using __atomic_val_t = typename atomic<_Tp>::value_type; + using __atomic_val_t = __type_identity_t<_Tp>; template using __atomic_diff_t = typename atomic<_Tp>::difference_type; 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 +#include + +struct Abstract { virtual void test() = 0; }; +struct Concrete : Abstract { virtual void test() override {} }; + +int main() { + std::shared_ptr ptr; + std::atomic_store(&ptr, std::make_shared()); +}