diff --git a/libcxx/include/__mdspan/layout_left.h b/libcxx/include/__mdspan/layout_left.h --- a/libcxx/include/__mdspan/layout_left.h +++ b/libcxx/include/__mdspan/layout_left.h @@ -164,7 +164,7 @@ _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( __r < extents_type::rank(), "layout_left::mapping::stride(): invalid rank index"); index_type __s = 1; - for (rank_type __i = extents_type::rank() - 1; __i > __r; __i--) + for (rank_type __i = 0; __i < __r; __i++) __s *= __extents_.extent(__i); return __s; } diff --git a/libcxx/test/std/containers/views/mdspan/layout_left/stride.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_left/stride.pass.cpp --- a/libcxx/test/std/containers/views/mdspan/layout_left/stride.pass.cpp +++ b/libcxx/test/std/containers/views/mdspan/layout_left/stride.pass.cpp @@ -39,8 +39,8 @@ constexpr size_t D = std::dynamic_extent; test_stride>(std::array{1}, 7); test_stride>(std::array{1}); - test_stride>(std::array{8, 1}); - test_stride>(std::array{720, 90, 10, 1}, 7, 9, 10); + test_stride>(std::array{1, 7}); + test_stride>(std::array{1, 7, 56, 504}, 7, 9, 10); return true; }