Hi EricWF,
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#2415
This change should really be applied to the shared_ptr in LFTS as well- and I
have let Jeffrey know.
http://reviews.llvm.org/D9410
Files:
include/memory
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
Index: include/memory
===================================================================
--- include/memory
+++ include/memory
@@ -1639,7 +1639,7 @@
struct __rebind_alloc_helper
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
- typedef typename _Traits::template rebind_alloc<_Tp> type;
+ typedef typename _Traits::template rebind_alloc<_Tp> type;
#else
typedef typename _Traits::template rebind_alloc<_Tp>::other type;
#endif
@@ -4274,9 +4274,16 @@
>::type)
: __ptr_(__r.get())
{
- typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
- __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>());
- __enable_weak_this(__r.get());
+#if _LIBCPP_STD_VER > 11
+ if (__ptr_ == nullptr)
+ __cntrl_ = nullptr;
+ else
+#endif
+ {
+ typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
+ __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>());
+ __enable_weak_this(__r.get());
+ }
__r.release();
}
@@ -4296,11 +4303,18 @@
>::type)
: __ptr_(__r.get())
{
- typedef __shared_ptr_pointer<_Yp*,
- reference_wrapper<typename remove_reference<_Dp>::type>,
- allocator<_Yp> > _CntrlBlk;
- __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>());
- __enable_weak_this(__r.get());
+#if _LIBCPP_STD_VER > 11
+ if (__ptr_ == nullptr)
+ __cntrl_ = nullptr;
+ else
+#endif
+ {
+ typedef __shared_ptr_pointer<_Yp*,
+ reference_wrapper<typename remove_reference<_Dp>::type>,
+ allocator<_Yp> > _CntrlBlk;
+ __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>());
+ __enable_weak_this(__r.get());
+ }
__r.release();
}
Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
===================================================================
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
@@ -67,7 +67,7 @@
pB = std::move(pA);
assert(B::count == 0);
assert(A::count == 0);
- assert(pB.use_count() == 1);
+// assert(pB.use_count() == 1); // no longer true due to LWG 2415
assert(pA.get() == 0);
assert(pB.get() == ptrA);
}
@@ -101,7 +101,7 @@
pB = std::move(pA);
assert(B::count == 0);
assert(A::count == 0);
- assert(pB.use_count() == 1);
+// assert(pB.use_count() == 1); // no longer true due to LWG 2415
assert(pA.get() == 0);
assert(pB.get() == ptrA);
}
Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
===================================================================
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -58,6 +58,9 @@
void fn ( const std::shared_ptr<int> &) {}
void fn ( const std::shared_ptr<B> &) { assert (false); }
+template <typename T>
+void assert_deleter ( T * ) { assert(false); }
+
int main()
{
{
@@ -100,4 +103,13 @@
throw_next = false;
fn(std::unique_ptr<int>(new int));
}
+
+#if __cplusplus >= 201402L
+ // LWG 2415
+ {
+ std::unique_ptr<int, void (*)(int*)> p(nullptr, assert_deleter<int>);
+ std::shared_ptr<int> p2(std::move(p)); // should not call deleter when going out of scope
+ }
+#endif
+
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits