From 0a000873392308fd0f4b4286b16814c5f3d8f41e Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Sun, 18 Jun 2023 00:48:22 +0800 Subject: [PATCH] Implement LWG-3893 --- stl/inc/memory | 4 ++++ tests/std/tests/P0718R2_atomic_smart_ptrs/test.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/stl/inc/memory b/stl/inc/memory index 00a358493d1..5ed5de5528f 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -4003,6 +4003,10 @@ public: store(_STD move(_Value)); } + void operator=(nullptr_t) noexcept { + store(nullptr); + } + ~atomic() { const auto _Rep = this->_Repptr._Unsafe_load_relaxed(); if (_Rep) { diff --git a/tests/std/tests/P0718R2_atomic_smart_ptrs/test.cpp b/tests/std/tests/P0718R2_atomic_smart_ptrs/test.cpp index 710a09a4545..0150911878d 100644 --- a/tests/std/tests/P0718R2_atomic_smart_ptrs/test.cpp +++ b/tests/std/tests/P0718R2_atomic_smart_ptrs/test.cpp @@ -2,9 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include +#include #include #include #include +#include #ifdef _DEBUG #include #endif // _DEBUG @@ -632,6 +634,13 @@ int main() { ensure_member_calls_compile>>(); ensure_member_calls_compile>>(); + // LWG-3893: LWG 3661 broke atomic> a; a = nullptr; + static_assert(is_nothrow_assignable_v>, nullptr_t>); + static_assert(is_nothrow_assignable_v>, nullptr_t>); + static_assert(is_nothrow_assignable_v>, nullptr_t>); + static_assert(is_nothrow_assignable_v>, nullptr_t>); + static_assert(is_nothrow_assignable_v>, nullptr_t>); + #ifdef _DEBUG sptr0 = {}; sptr1 = {};