From: Louis Dionne Date: Tue, 11 Apr 2023 16:53:39 +0000 (+0100) Subject: [libc++] Remove redundant assertion in std::span::subspan X-Git-Tag: upstream/17.0.6~11608 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3865e084b2ef9908bdca519b90f02ddde737a4a3;p=platform%2Fupstream%2Fllvm.git [libc++] Remove redundant assertion in std::span::subspan That is already checked later in the function as `__count <= size() - __offset`. rdar://107884996 Differential Revision: https://reviews.llvm.org/D148030 --- diff --git a/libcxx/include/span b/libcxx/include/span index 2ef1ea6..0464c94 100644 --- a/libcxx/include/span +++ b/libcxx/include/span @@ -327,7 +327,6 @@ public: subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept { _LIBCPP_ASSERT(__offset <= size(), "span::subspan(offset, count): offset out of range"); - _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span::subspan(offset, count): count out of range"); if (__count == dynamic_extent) return {data() + __offset, size() - __offset}; _LIBCPP_ASSERT(__count <= size() - __offset, "span::subspan(offset, count): offset + count out of range"); @@ -493,7 +492,6 @@ public: subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept { _LIBCPP_ASSERT(__offset <= size(), "span::subspan(offset, count): offset out of range"); - _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span::subspan(offset, count): count out of range"); if (__count == dynamic_extent) return {data() + __offset, size() - __offset}; _LIBCPP_ASSERT(__count <= size() - __offset, "span::subspan(offset, count): offset + count out of range"); diff --git a/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp index a66ca54..f7f1736 100644 --- a/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp +++ b/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp @@ -38,7 +38,7 @@ int main(int, char**) { TEST_LIBCPP_ASSERT_FAILURE(s.subspan(4), "span::subspan(offset, count): offset out of range"); TEST_LIBCPP_ASSERT_FAILURE(s.subspan<4>(), "span::subspan(): Offset out of range"); - TEST_LIBCPP_ASSERT_FAILURE(s.subspan(0, 4), "span::subspan(offset, count): count out of range"); + TEST_LIBCPP_ASSERT_FAILURE(s.subspan(0, 4), "span::subspan(offset, count): offset + count out of range"); TEST_LIBCPP_ASSERT_FAILURE((s.subspan<0, 4>()), "span::subspan(): Offset + Count out of range"); TEST_LIBCPP_ASSERT_FAILURE(s.subspan(1, 3), "span::subspan(offset, count): offset + count out of range"); @@ -50,7 +50,7 @@ int main(int, char**) { TEST_LIBCPP_ASSERT_FAILURE(s.subspan(4), "span::subspan(offset, count): offset out of range"); // s.subspan<4>() caught at compile-time (tested in libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp) - TEST_LIBCPP_ASSERT_FAILURE(s.subspan(0, 4), "span::subspan(offset, count): count out of range"); + TEST_LIBCPP_ASSERT_FAILURE(s.subspan(0, 4), "span::subspan(offset, count): offset + count out of range"); // s.subspan<0, 4>() caught at compile-time (tested in libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp) TEST_LIBCPP_ASSERT_FAILURE(s.subspan(1, 3), "span::subspan(offset, count): offset + count out of range");