[libcxx-commits] [libcxx] [libc++] Fix value category issues in `mdspan::operator[]` bounds checking (PR #192269)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 16 08:49:21 PDT 2026
================
@@ -191,11 +191,15 @@ class mdspan {
(is_nothrow_constructible_v<index_type, _OtherIndexTypes> && ...) &&
(sizeof...(_OtherIndexTypes) == rank()))
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](_OtherIndexTypes... __indices) const {
- // Note the standard layouts would also check this, but user provided ones may not, so we
- // check the precondition here
- _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__mdspan_detail::__is_multidimensional_index_in(extents(), __indices...),
- "mdspan: operator[] out of bounds access");
----------------
eiytoq wrote:
The root cause is that the hardening check misses `std::move` on the indices.
https://github.com/llvm/llvm-project/pull/192269
More information about the libcxx-commits
mailing list