]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Skip redundant assertions in std::span construction [PR117966]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 9 Dec 2024 17:35:24 +0000 (17:35 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 16 Apr 2025 17:47:39 +0000 (18:47 +0100)
commit7b0f505650310c11455ee7d34f95008658d3e655
tree5862d5ff4860d7692af48b94f9d75f48a0e99058
parent9357f7e0fbfbf0d7d5adb2cd1588a765f40b6162
libstdc++: Skip redundant assertions in std::span construction [PR117966]

As PR c++/117966 shows, the Debug Mode checks cause a compilation error
for a global constexpr std::span. Those debug checks are redundant when
constructing from an array or a range, because we already know we have a
valid range and we know its size. Instead of delegating to the
std::span(contiguous_iterator, contiguous_iterator) constructor, just
initialize the data members directly.

libstdc++-v3/ChangeLog:

PR libstdc++/117966
* include/std/span (span(T (&)[N])): Do not delegate to
constructor that performs redundant checks.
(span(array<T, N>&), span(const array<T, N>&)): Likewise.
(span(Range&&), span(const span<T, N>&)): Likewise.
* testsuite/23_containers/span/117966.cc: New test.

(cherry picked from commit e95bda027e0b81922c1bf44770674190bdf787e8)
libstdc++-v3/include/std/span
libstdc++-v3/testsuite/23_containers/span/117966.cc [new file with mode: 0644]