Skip to content

Commit 5b5634f

Browse files
fsb4000miscco
andauthored
LWG-3661: constinit atomic<shared_ptr<T>> a(nullptr); should work (#2544)
Co-authored-by: Michael Schellenberger Costa <[email protected]>
1 parent e472b13 commit 5b5634f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

stl/inc/memory

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3953,6 +3953,8 @@ public:
39533953

39543954
constexpr atomic() noexcept = default;
39553955

3956+
constexpr atomic(nullptr_t) noexcept : atomic() {}
3957+
39563958
atomic(const shared_ptr<_Ty> _Value) noexcept : _Base(_Value._Ptr, _Value._Rep) {
39573959
_Value._Incref();
39583960
}

tests/std/tests/P0718R2_atomic_smart_ptrs/test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ void ensure_nonmember_calls_compile() {
222222
}
223223
}
224224

225+
#ifndef __EDG__ // TRANSITION, DevCom-1656924
226+
// LWG-3661: constinit atomic<shared_ptr<T>> a(nullptr); should work
227+
constinit atomic<shared_ptr<bool>> a{};
228+
constinit atomic<shared_ptr<bool>> b{nullptr};
229+
#endif // __EDG__
230+
225231
int main() {
226232
// These values for is_always_lock_free are not required by the standard, but they are true for our implementation.
227233
static_assert(atomic<shared_ptr<int>>::is_always_lock_free == false);

0 commit comments

Comments
 (0)