diff options
author | Patrick Palka <ppalka@redhat.com> | 2020-09-21 20:53:17 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2020-09-21 23:21:34 -0400 |
commit | 37edf28c24b7bd198c27d266af9aefad417635fd (patch) | |
tree | c147da811dc76f898741530ace441b2084670680 /libstdc++-v3/include/std/span | |
parent | 813ad9c4dd5a779f12ad2abf710c6e75a3117ef0 (diff) | |
download | gcc-37edf28c24b7bd198c27d266af9aefad417635fd.zip gcc-37edf28c24b7bd198c27d266af9aefad417635fd.tar.gz gcc-37edf28c24b7bd198c27d266af9aefad417635fd.tar.bz2 |
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[].
Diffstat (limited to 'libstdc++-v3/include/std/span')
-rw-r--r-- | libstdc++-v3/include/std/span | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span index f658adb..1cdc058 100644 --- a/libstdc++-v3/include/std/span +++ b/libstdc++-v3/include/std/span @@ -264,7 +264,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr reference front() const noexcept { - static_assert(extent != 0); __glibcxx_assert(!empty()); return *this->_M_ptr; } @@ -272,7 +271,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr reference back() const noexcept { - static_assert(extent != 0); __glibcxx_assert(!empty()); return *(this->_M_ptr + (size() - 1)); } @@ -280,7 +278,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr reference operator[](size_type __idx) const noexcept { - static_assert(extent != 0); __glibcxx_assert(__idx < size()); return *(this->_M_ptr + __idx); } |