[libcxx-commits] [PATCH] D117996: [libcxx][test] Disable bad unique_ptr<T[]> to shared_ptr<U[]> conversion test cases

Casey Carter via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 23 10:33:05 PST 2022


CaseyCarter created this revision.
CaseyCarter added a reviewer: libc++.
CaseyCarter added a project: libc++.
CaseyCarter requested review of this revision.
Herald added 1 blocking reviewer(s): libc++.

for non-libc++. As commented in the code, these conversions are forbidden by the "`Y*` is compatible with `T*`" constraints.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117996

Files:
  libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
  libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp


Index: libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
===================================================================
--- libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+++ libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -149,6 +149,8 @@
     }
 
     assert(A::count == 0);
+#ifdef _LIBCPP_VERSION // Bogus test cases initialize shared_ptr<T> with unique_ptr<Y> despite that
+                       // Y* and T* are not compatible per [util.smartptr.shared.general]/6.
     {
       std::unique_ptr<A[]> ptr(new A[8]);
       A* raw_ptr = ptr.get();
@@ -177,6 +179,7 @@
       std::unique_ptr<int[]> ptr(new int[8]);
       std::shared_ptr<int> p(std::move(ptr));
     }
+#endif // _LIBCPP_VERSION
 
 #if TEST_STD_VER > 14
     {
@@ -189,6 +192,8 @@
     assert(A::count == 0);
     assert(B::count == 0);
 
+#ifdef _LIBCPP_VERSION // Bogus test case initializes shared_ptr<T> with unique_ptr<Y> despite that
+                       // Y* and T* are not compatible per [util.smartptr.shared.general]/6.
     {
       std::unique_ptr<A[]> ptr(new A[8]);
       A* raw_ptr = ptr.get();
@@ -201,6 +206,7 @@
     }
     assert(A::count == 0);
     assert(B::count == 0);
+#endif // _LIBCPP_VERSION
 
     {
       std::unique_ptr<A[]> ptr(new A[8]);
Index: libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
===================================================================
--- libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
+++ libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
@@ -125,6 +125,8 @@
     assert(B::count == 0);
     assert(A::count == 0);
 
+#ifdef _LIBCPP_VERSION // Bogus test cases assign unique_ptr<Y> to shared_ptr<T> despite that
+                       // Y* and T* are not compatible per [util.smartptr.shared.general]/6.
     {
       std::unique_ptr<A[]> ptr(new A[8]);
       A* raw_ptr = ptr.get();
@@ -156,6 +158,7 @@
       std::shared_ptr<int> p;
       p = std::move(ptr);
     }
+#endif // _LIBCPP_VERSION
 
 #if TEST_STD_VER > 14
     {
@@ -169,6 +172,8 @@
     assert(A::count == 0);
     assert(B::count == 0);
 
+#ifdef _LIBCPP_VERSION // Bogus test case assigns unique_ptr<Y> to shared_ptr<T> despite that
+                       // Y* and T* are not compatible per [util.smartptr.shared.general]/6.
     {
       std::unique_ptr<A[]> ptr(new A[8]);
       A* raw_ptr = ptr.get();
@@ -182,6 +187,7 @@
     }
     assert(A::count == 0);
     assert(B::count == 0);
+#endif // _LIBCPP_VERSION
 
     {
       std::unique_ptr<A[]> ptr(new A[8]);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117996.402352.patch
Type: text/x-patch
Size: 2896 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220123/78620e49/attachment.bin>


More information about the libcxx-commits mailing list