[PATCH] D22014: [libcxx] [test] Follow LWG 2520 "N4089 broke initializing unique_ptr<T[]> from a nullptr".

Stephan T. Lavavej via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 5 13:49:13 PDT 2016


STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

Follow LWG 2520 "N4089 broke initializing unique_ptr<T[]> from a nullptr".

This library issue permits nullptr, but not 0 or NULL (which can be 0). In null_ctor.pass.cpp, replace 0 with nullptr. In pointer_deleter01.pass.cpp, which is testing both NULL and nullptr, mark the NULL test as libcxx-specific.

http://reviews.llvm.org/D22014

Files:
  test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
  test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp

Index: test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
===================================================================
--- test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
+++ test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
@@ -42,7 +42,9 @@
     assert(A::count == 0);
 
     { // LWG#2520 says that nullptr is a valid input as well as null
+#ifdef _LIBCPP_VERSION
     std::unique_ptr<A[], Deleter<A[]> > s1(NULL, Deleter<A[]>());
+#endif
     std::unique_ptr<A[], Deleter<A[]> > s2(nullptr, Deleter<A[]>());
     }
     assert(A::count == 0);
Index: test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
===================================================================
--- test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
+++ test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
@@ -36,7 +36,7 @@
     Deleter d;
     assert(d.state() == 0);
     {
-    std::unique_ptr<int[], Deleter&> p(0, d);
+    std::unique_ptr<int[], Deleter&> p(nullptr, d);
     assert(p.get() == 0);
     assert(&p.get_deleter() == &d);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22014.62785.patch
Type: text/x-patch
Size: 1275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160705/7255d979/attachment.bin>


More information about the cfe-commits mailing list