libstdc++: Fix bug in std::span test
authorJonathan Wakely <jwakely@redhat.com>
Thu, 5 Dec 2019 13:50:08 +0000 (13:50 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 5 Dec 2019 13:50:08 +0000 (13:50 +0000)
The previous commit fixed the std::span constructors from const arrays,
revealing a bug in this test.

* testsuite/23_containers/span/lwg3255.cc: Fix test. Constructing a
span of non-const elements should not be possible from a const array
or an array of const elements.

From-SVN: r279001

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/23_containers/span/lwg3255.cc

index 82cb5a9..b041bb4 100644 (file)
@@ -1,3 +1,9 @@
+2019-12-05  Jonathan Wakely  <jwakely@redhat.com>
+
+       * testsuite/23_containers/span/lwg3255.cc: Fix test. Constructing a
+       span of non-const elements should not be possible from a const array
+       or an array of const elements.
+
 2019-12-05  JeanHeyd "ThePhD" Meneide  <phdofthehouse@gmail.com>
 
        Implement P1872R0 and P1394R0 for std::span
index bab7da3..eec686b 100644 (file)
@@ -39,7 +39,6 @@ static_assert( is_constructible_v<span<int, 1>, array<int, 1>&> );
 static_assert( is_constructible_v<span<const int, 1>, array<int, 1>&> );
 static_assert( is_constructible_v<span<const int, 1>, array<const int, 1>&> );
 
-static_assert( is_constructible_v<span<int, 1>, const array<int, 1>&> );
 static_assert( is_constructible_v<span<const int, 1>, const array<int, 1>&> );
 static_assert( is_constructible_v<span<const int, 1>, const array<const int, 1>&> );
 
@@ -63,6 +62,12 @@ static_assert( is_constructible_v<span<int>, array<int, 2>&> );
 static_assert( is_constructible_v<span<const int>, array<int, 2>&> );
 static_assert( is_constructible_v<span<const int>, array<const int, 2>&> );
 
-static_assert( is_constructible_v<span<int>, const array<int, 2>&> );
 static_assert( is_constructible_v<span<const int>, const array<int, 2>&> );
 static_assert( is_constructible_v<span<const int>, const array<const int, 2>&> );
+
+static_assert( ! is_constructible_v<span<int, 1>, array<const int, 1>&> );
+static_assert( ! is_constructible_v<span<int, 1>, const array<int, 1>&> );
+static_assert( ! is_constructible_v<span<int, 1>, const array<const int, 1>&> );
+static_assert( ! is_constructible_v<span<int>, array<const int, 2>&> );
+static_assert( ! is_constructible_v<span<int>, const array<int, 2>&> );
+static_assert( ! is_constructible_v<span<int>, const array<const int, 2>&> );