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

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 4 02:09:57 PST 2024


================
@@ -267,6 +267,8 @@ public:
   _LIBCPP_HIDE_FROM_ABI constexpr explicit span(_It __first, size_type __count) : __data_{std::to_address(__first)} {
     (void)__count;
     _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Extent == __count, "size mismatch in span's constructor (iterator, len)");
+    _LIBCPP_ASSERT_VALID_INPUT_RANGE(__count == 0 ? true : std::to_address(__first) != nullptr,
----------------
philnik777 wrote:

```suggestion
    _LIBCPP_ASSERT_VALID_INPUT_RANGE(__count == 0 || std::to_address(__first) != nullptr,
```

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


More information about the libcxx-commits mailing list