[libcxx-commits] [libcxx] [libc++] Add missing assertion in std::span constructor (PR #118396)

Konstantin Varlamov via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 4 12:22:59 PST 2024


================
@@ -25,13 +25,48 @@
 #include "check_assertion.h"
 
 int main(int, char**) {
-    std::array<int, 3> array{0, 1, 2};
+  std::array<int, 3> array{0, 1, 2};
 
-    auto too_large = [&] { std::span<int, 3> const s(array.data(), 4); (void)s; };
-    TEST_LIBCPP_ASSERT_FAILURE(too_large(), "size mismatch in span's constructor (iterator, len)");
+  // Providing too large value in constructor
----------------
var-const wrote:

Optional: how about changing these comments slightly to something like:
```cpp
// Input range too large (exceeds the span extent)
// Input range too small (doesn't fill the span)
// Input range is non-empty but starts with a null pointer
```
?

https://github.com/llvm/llvm-project/pull/118396


More information about the libcxx-commits mailing list