[PATCH] D55364: [libcxx] Portability fix: make return value of array<T, 0>.data() checked only for libc++.

Andrey Maksimov via Phabricator reviews at reviews.llvm.org
Thu Dec 6 05:01:53 PST 2018


amakc11 created this revision.
Herald added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, ldionne.

The section [[ http://eel.is/c++draft/array.zero#2 | [array.zero] ]] says: "The return value of data() is unspecified". This patch marks all checks of the `array<T, 0>.data()` return value as libc++ specific.


Repository:
  rCXX libc++

https://reviews.llvm.org/D55364

Files:
  test/std/containers/sequences/array/array.data/data.pass.cpp
  test/std/containers/sequences/array/array.data/data_const.pass.cpp


Index: test/std/containers/sequences/array/array.data/data_const.pass.cpp
===================================================================
--- test/std/containers/sequences/array/array.data/data_const.pass.cpp
+++ test/std/containers/sequences/array/array.data/data_const.pass.cpp
@@ -48,14 +48,14 @@
       typedef std::array<T, 0> C;
       const C c = {};
       const T* p = c.data();
-      assert(p != nullptr);
+      LIBCPP_ASSERT(p != nullptr);
     }
     {
       typedef std::max_align_t T;
       typedef std::array<T, 0> C;
       const C c = {};
       const T* p = c.data();
-      assert(p != nullptr);
+      LIBCPP_ASSERT(p != nullptr);
       std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
       assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
     }
Index: test/std/containers/sequences/array/array.data/data.pass.cpp
===================================================================
--- test/std/containers/sequences/array/array.data/data.pass.cpp
+++ test/std/containers/sequences/array/array.data/data.pass.cpp
@@ -42,7 +42,7 @@
         typedef std::array<T, 0> C;
         C c = {};
         T* p = c.data();
-        assert(p != nullptr);
+        LIBCPP_ASSERT(p != nullptr);
     }
     {
       typedef double T;
@@ -50,14 +50,14 @@
       C c = {{}};
       const T* p = c.data();
       static_assert((std::is_same<decltype(c.data()), const T*>::value), "");
-      assert(p != nullptr);
+      LIBCPP_ASSERT(p != nullptr);
     }
   {
       typedef std::max_align_t T;
       typedef std::array<T, 0> C;
       const C c = {};
       const T* p = c.data();
-      assert(p != nullptr);
+      LIBCPP_ASSERT(p != nullptr);
       std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
       assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
     }
@@ -66,6 +66,6 @@
       typedef std::array<T, 0> C;
       C c = {};
       T* p = c.data();
-      assert(p != nullptr);
+      LIBCPP_ASSERT(p != nullptr);
     }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55364.176951.patch
Type: text/x-patch
Size: 1979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20181206/06d3488a/attachment.bin>


More information about the libcxx-commits mailing list