]> 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 <redi@gcc.gnu.org>
Thu, 9 Jan 2025 23:52:29 +0000 (23:52 +0000)
commit83fa0822aeec8af2162825976209efb90ca40c87
treef03137faa97bcbc401f114a4a94a85ebc3affdcf
parent67c457de5a3f74151fc2d0085387127bf9e4e3c5
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]