diff --git a/stl/inc/memory b/stl/inc/memory index de4addfbe74..50c94371a2a 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -1642,7 +1642,8 @@ public: if (_Fancy) { const _Raw_t _Raw = _Fancy; - const auto _Rx = new _Ref_count_resource<_Fancy_t, _Deleter_t>(_Fancy, _Other.get_deleter()); + const auto _Rx = + new _Ref_count_resource<_Fancy_t, _Deleter_t>(_Fancy, _STD forward<_Dx>(_Other.get_deleter())); _Set_ptr_rep_and_enable_shared(_Raw, _Rx); _Other.release(); } diff --git a/tests/std/tests/Dev10_722102_shared_ptr_nullptr/test.cpp b/tests/std/tests/Dev10_722102_shared_ptr_nullptr/test.cpp index 75eca42e39d..b56b97b9863 100644 --- a/tests/std/tests/Dev10_722102_shared_ptr_nullptr/test.cpp +++ b/tests/std/tests/Dev10_722102_shared_ptr_nullptr/test.cpp @@ -211,6 +211,14 @@ namespace unique_ptr_ { assert(*ptr.ptr_ == 42); *ptr.ptr_ = 13; } + + // Also test LWG-3548 "shared_ptr construction from unique_ptr should move (not copy) the deleter". + fancy_deleter() = default; + fancy_deleter(fancy_deleter&&) = default; + + fancy_deleter(const fancy_deleter&) = delete; + fancy_deleter& operator=(fancy_deleter&&) = delete; + fancy_deleter& operator=(const fancy_deleter&) = delete; }; template