]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Remove overzealous static_asserts from std::span
authorPatrick Palka <ppalka@redhat.com>
Tue, 22 Sep 2020 00:53:17 +0000 (20:53 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 21 Oct 2020 18:04:06 +0000 (14:04 -0400)
commiteab76310e665a7d06e8ff9e8c8da44ddc5adc586
tree2350c5b8bca673ef102bc6755330667953518fdc
parent36ee59a2640712a6e24d9e27290bc5ebbef39709
libstdc++: Remove overzealous static_asserts from std::span

For a span with statically empty extent, we currently model the
preconditions of front(), back(), and operator[] as if they are
mandates, by using a static_assert to verify that extent != 0.  This
causes us to reject valid programs that would instantiate these member
functions and at runtime never call them.

Since they are already followed by more general runtime asserts, this
patch just removes these static_asserts altogether,

libstdc++-v3/ChangeLog:

* include/std/span (span::front): Remove static_assert.
(span::back): Likewise.
(span::operator[]): Likewise.
* testsuite/23_containers/span/back_neg.cc: Rewrite to verify
that we check the preconditions of back() only when it's called.
* testsuite/23_containers/span/front_neg.cc: Likewise for
front().
* testsuite/23_containers/span/index_op_neg.cc: Likewise for
operator[].

(cherry picked from commit 37edf28c24b7bd198c27d266af9aefad417635fd)
libstdc++-v3/include/std/span
libstdc++-v3/testsuite/23_containers/span/back_neg.cc
libstdc++-v3/testsuite/23_containers/span/front_neg.cc
libstdc++-v3/testsuite/23_containers/span/index_op_neg.cc
This page took 0.056238 seconds and 6 git commands to generate.