Skip to content

Commit 219cef0

Browse files
crtrotttru
authored andcommitted
[libc++][mdspan] Fix layout_left::stride(r)
It was using the stride calculation of layout_right. Reviewed By: philnik Differential Revision: https://reviews.llvm.org/D157065 (cherry picked from commit 0f4d7d8)
1 parent 79d850a commit 219cef0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

libcxx/include/__mdspan/layout_left.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class layout_left::mapping {
164164
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
165165
__r < extents_type::rank(), "layout_left::mapping::stride(): invalid rank index");
166166
index_type __s = 1;
167-
for (rank_type __i = extents_type::rank() - 1; __i > __r; __i--)
167+
for (rank_type __i = 0; __i < __r; __i++)
168168
__s *= __extents_.extent(__i);
169169
return __s;
170170
}

libcxx/test/std/containers/views/mdspan/layout_left/stride.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ constexpr bool test() {
3939
constexpr size_t D = std::dynamic_extent;
4040
test_stride<std::extents<unsigned, D>>(std::array<unsigned, 1>{1}, 7);
4141
test_stride<std::extents<unsigned, 7>>(std::array<unsigned, 1>{1});
42-
test_stride<std::extents<unsigned, 7, 8>>(std::array<unsigned, 2>{8, 1});
43-
test_stride<std::extents<int64_t, D, 8, D, D>>(std::array<int64_t, 4>{720, 90, 10, 1}, 7, 9, 10);
42+
test_stride<std::extents<unsigned, 7, 8>>(std::array<unsigned, 2>{1, 7});
43+
test_stride<std::extents<int64_t, D, 8, D, D>>(std::array<int64_t, 4>{1, 7, 56, 504}, 7, 9, 10);
4444
return true;
4545
}
4646

0 commit comments

Comments
 (0)