[PATCH RFC] libstdc++: use contract_assert for __glibcxx_assert
Jonathan Wakely
jwakely@redhat.com
Mon Nov 16 09:36:33 GMT 2026
On Fri, 13 Nov 2026 at 15:39 -0500, Jason Merrill wrote:
>Tested x86_64-pc-linux-gnu.
>
>I assume you don't want to condition this on only __cpp_contracts as in the
>current patch. And I don't know how you want to handle the view_interface
>empty() issue. But I think the rest of the patch could go in as is. Thoughts?
>
>-- 8< --
>
>To get some usage experience with contracts, this uses contract_assert for
>libstdc++ asserts when available. Well, __contract_assert as long as the
>keyword without __ requires -std=c++26, not just -fcontracts.
>
>Constification required a few adjustments, mostly adding trivial const
>overloads.
>
>It also caught =/== bugs in some debug asserts that date back to 2005.
>
>In view_interface::front I needed to avoid constification because empty()
>for a const object argument currently fails to compile.
>
>libstdc++-v3/ChangeLog:
>
> * include/bits/c++config (__glibcxx_assert): Use contract_assert if
> available.
> * include/bits/node_handle.h (_NodeAlloc::operator*)
> * include/bits/regex_executor.h (_Executor::_M_get_sol_pos): Add
> const overload.
> * include/bits/ranges_util.h (view_interface::front): Work around
> empty() being broken for a const object argument.
> * include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp
> * include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp
> * include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp: Fix =/== typo.
> * testsuite/20_util/constant_wrapper/type_param_neg.cc
> * testsuite/20_util/expected/illformed_neg.cc
> * testsuite/20_util/function_ref/cons_neg.cc
> * testsuite/20_util/function_ref/cw_cons_neg.cc
> * testsuite/20_util/has_unique_object_representations/neg.cc
> * testsuite/20_util/optional/monadic/or_else_neg.cc
> * testsuite/20_util/optional/monadic/ref_neg.cc
> * testsuite/20_util/optional/ref/make_optional/from_args_neg.cc
> * testsuite/20_util/optional/ref/make_optional/from_lvalue_neg.cc
> * testsuite/20_util/optional/ref/make_optional/from_rvalue_neg.cc
> * testsuite/20_util/stdbit/2_neg.cc
> * testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc
> * testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc
> * testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc
> * testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc
> * testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc
> * testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc
> * testsuite/21_strings/basic_string_view/modifiers/remove_prefix/debug.cc
> * testsuite/21_strings/basic_string_view/modifiers/remove_suffix/debug.cc
> * testsuite/21_strings/basic_string_view/requirements/traits_neg.cc
> * testsuite/23_containers/array/creation/3_neg.cc
> * testsuite/23_containers/array/element_access/constexpr_c++17.cc
> * testsuite/23_containers/inplace_vector/access/elem_neg.cc
> * testsuite/23_containers/inplace_vector/modifiers/erase_neg.cc
> * testsuite/23_containers/inplace_vector/modifiers/single_insert_neg.cc
> * testsuite/23_containers/mdspan/accessors/aligned_neg.cc
> * testsuite/23_containers/mdspan/class_mandate_neg.cc
> * testsuite/23_containers/mdspan/extents/class_mandates_neg.cc
> * testsuite/23_containers/mdspan/extents/extents_mismatch_neg.cc
> * testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc
> * testsuite/23_containers/mdspan/layouts/debug/out_of_bounds_neg.cc
> * testsuite/23_containers/mdspan/layouts/padded_neg.cc
> * testsuite/23_containers/mdspan/layouts/stride_debug_neg.cc
> * testsuite/23_containers/mdspan/layouts/stride_neg.cc
> * testsuite/23_containers/mdspan/out_of_bounds_neg.cc
> * testsuite/23_containers/mdspan/submdspan/canonical_slices_neg.cc
> * testsuite/23_containers/mdspan/submdspan/extent_slice_neg.cc
> * testsuite/23_containers/mdspan/submdspan/subextents_neg.cc
> * testsuite/23_containers/mdspan/submdspan/submdspan_neg.cc
> * testsuite/23_containers/span/back_neg.cc
> * testsuite/23_containers/span/front_neg.cc
> * testsuite/23_containers/span/index_op_neg.cc
> * testsuite/23_containers/vector/bool/element_access/constexpr.cc
> * testsuite/23_containers/vector/element_access/constexpr.cc
> * testsuite/25_algorithms/clamp/118185.cc
> * testsuite/26_numerics/lcm/105844.cc
> * testsuite/26_numerics/random/piecewise_constant_distribution/cons/*
> * testsuite/26_numerics/random/piecewise_linear_distribution/cons/input_type_fallback_neg.cc
> * testsuite/26_numerics/stdckdint/2_neg.cc
> * testsuite/30_threads/semaphore/cons_neg.cc
> * testsuite/std/memory/start_lifetime_as/neg.cc: Handle contract
> diagnostics.
>
>gcc/testsuite/ChangeLog:
>
> * g++.dg/reflect/parameters_of4.C: Handle contract diagnostics.
> * g++.dg/reflect/splicing-base4.C: Likewise.
>---
> libstdc++-v3/include/bits/node_handle.h | 1 +
> libstdc++-v3/include/bits/ranges_util.h | 4 +++-
> libstdc++-v3/include/bits/regex_executor.h | 1 +
> gcc/testsuite/g++.dg/reflect/parameters_of4.C | 2 +-
> gcc/testsuite/g++.dg/reflect/splicing-base4.C | 2 +-
> .../20_util/constant_wrapper/type_param_neg.cc | 1 +
> .../testsuite/20_util/expected/illformed_neg.cc | 1 +
> .../testsuite/20_util/function_ref/cons_neg.cc | 1 +
> .../testsuite/20_util/function_ref/cw_cons_neg.cc | 1 +
> .../20_util/has_unique_object_representations/neg.cc | 1 +
> .../20_util/optional/monadic/or_else_neg.cc | 1 +
> .../testsuite/20_util/optional/monadic/ref_neg.cc | 1 +
> .../optional/ref/make_optional/from_args_neg.cc | 1 +
> .../optional/ref/make_optional/from_lvalue_neg.cc | 1 +
> .../optional/ref/make_optional/from_rvalue_neg.cc | 1 +
> libstdc++-v3/testsuite/20_util/stdbit/2_neg.cc | 1 +
> .../element_access/char/back_constexpr_neg.cc | 2 +-
> .../element_access/char/constexpr_neg.cc | 4 ++--
> .../element_access/char/front_constexpr_neg.cc | 4 ++--
> .../element_access/wchar_t/back_constexpr_neg.cc | 2 +-
> .../element_access/wchar_t/constexpr_neg.cc | 4 ++--
> .../element_access/wchar_t/front_constexpr_neg.cc | 4 ++--
> .../modifiers/remove_prefix/debug.cc | 2 +-
> .../modifiers/remove_suffix/debug.cc | 2 +-
> .../basic_string_view/requirements/traits_neg.cc | 1 +
> .../testsuite/23_containers/array/creation/3_neg.cc | 1 +
> .../array/element_access/constexpr_c++17.cc | 2 ++
> .../23_containers/inplace_vector/access/elem_neg.cc | 1 +
> .../inplace_vector/modifiers/erase_neg.cc | 1 +
> .../inplace_vector/modifiers/single_insert_neg.cc | 1 +
> .../23_containers/mdspan/accessors/aligned_neg.cc | 1 +
> .../23_containers/mdspan/class_mandate_neg.cc | 1 +
> .../mdspan/extents/class_mandates_neg.cc | 1 +
> .../mdspan/extents/extents_mismatch_neg.cc | 1 +
> .../mdspan/layouts/class_mandate_neg.cc | 1 +
> .../mdspan/layouts/debug/out_of_bounds_neg.cc | 1 +
> .../23_containers/mdspan/layouts/padded_neg.cc | 1 +
> .../23_containers/mdspan/layouts/stride_debug_neg.cc | 1 +
> .../23_containers/mdspan/layouts/stride_neg.cc | 1 +
> .../23_containers/mdspan/out_of_bounds_neg.cc | 1 +
> .../mdspan/submdspan/canonical_slices_neg.cc | 1 +
> .../mdspan/submdspan/extent_slice_neg.cc | 1 +
> .../23_containers/mdspan/submdspan/subextents_neg.cc | 1 +
> .../23_containers/mdspan/submdspan/submdspan_neg.cc | 1 +
> .../testsuite/23_containers/span/back_neg.cc | 2 +-
> .../testsuite/23_containers/span/front_neg.cc | 2 +-
> .../testsuite/23_containers/span/index_op_neg.cc | 2 +-
> .../vector/bool/element_access/constexpr.cc | 2 ++
> .../23_containers/vector/element_access/constexpr.cc | 2 ++
> libstdc++-v3/testsuite/25_algorithms/clamp/118185.cc | 2 +-
> libstdc++-v3/testsuite/26_numerics/lcm/105844.cc | 2 +-
> .../cons/input_type_fallback_neg.cc | 1 +
> .../cons/input_type_fallback_neg.cc | 1 +
> .../testsuite/26_numerics/stdckdint/2_neg.cc | 1 +
> .../testsuite/30_threads/semaphore/cons_neg.cc | 2 ++
> .../testsuite/std/memory/start_lifetime_as/neg.cc | 1 +
> .../pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp | 2 +-
> .../detail/gp_hash_table_map_/erase_fn_imps.hpp | 2 +-
> .../ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp | 2 +-
> libstdc++-v3/include/bits/c++config | 12 ++++++++++++
> 60 files changed, 81 insertions(+), 23 deletions(-)
>
>diff --git a/libstdc++-v3/include/bits/node_handle.h b/libstdc++-v3/include/bits/node_handle.h
>index 4bd191439a1..c484ccc9aa8 100644
>--- a/libstdc++-v3/include/bits/node_handle.h
>+++ b/libstdc++-v3/include/bits/node_handle.h
>@@ -223,6 +223,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>
> // Precondition: _M_alloc is the active member of the union.
> _NodeAlloc& operator*() noexcept { return _M_alloc; }
>+ const _NodeAlloc& operator*() const noexcept { return _M_alloc; }
This didn't exist because the only non-assertion uses of the function
are to get a mutable reference. But it's fine to add it. The type
models std::optional which has both const and non-const operator*.
>
> // Precondition: _M_alloc is the active member of the union.
> _NodeAlloc release() noexcept
>diff --git a/libstdc++-v3/include/bits/ranges_util.h b/libstdc++-v3/include/bits/ranges_util.h
>index 9e51aa53ec8..a814b60afae 100644
>--- a/libstdc++-v3/include/bits/ranges_util.h
>+++ b/libstdc++-v3/include/bits/ranges_util.h
>@@ -161,7 +161,9 @@ namespace ranges
> constexpr decltype(auto)
> front() requires forward_range<_Derived>
> {
>- __glibcxx_assert(!empty());
>+ // FIXME constified empty() breaks on combined views.
>+ bool _ = empty();
>+ __glibcxx_assert(!_);
views don't necessarly have a const empty() and calling the non-const
empty() can have side effects, although typically the same side
effects as calling ranges::begin would have anyway (i.e. caching the
begin iterator).
We _could_ do something like:
if constexpr (sized_range<const _Derived>
|| forward_range<const _Derived>)
__glibcxx_assert(empty());
else
{
bool empty = this->empty();
__glibcxx_assert(!empty);
}
But I don't think it's worth it.
I do think we should name the local variable 'empty' so that the
assertion failure text reads better, !_ would be confusing. Or just
use __glibcxx_assert(const_cast<view_interface*>(this)->empty()) but
that wouldn't give a great message either.
> return *ranges::begin(_M_derived());
> }
>
>diff --git a/libstdc++-v3/include/bits/regex_executor.h b/libstdc++-v3/include/bits/regex_executor.h
>index 51de0f52113..8c484abee11 100644
>--- a/libstdc++-v3/include/bits/regex_executor.h
>+++ b/libstdc++-v3/include/bits/regex_executor.h
>@@ -297,6 +297,7 @@ _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
> }
>
> _BiIter* _M_get_sol_pos() { return &_M_sol_pos; }
>+ const _BiIter* _M_get_sol_pos() const { return &_M_sol_pos; }
Based on a quick look at this code, I think the assertion using this
member is an internal debugging check, not a user-facing precondition.
Maybe we should just remove the assertion, since it would only fire if
there's a bug in the implementation, and that's not a precondition
violation and not something the user can fix. Especially as the
failure text would just say '_M_get_sol_pos()' which is meaningless to
the user.
I'm not aware of a bug report suggesting that assertion has ever
failed, so presumably we don't have any such bug in the implementation
and don't need to check for it (the next statement would segfault
anyway if we did have such a bug).
> public:
> _GLIBCXX_STD_C::vector<_ExecutorFrame<_BiIter>> _M_frames;
>diff --git a/gcc/testsuite/g++.dg/reflect/parameters_of4.C b/gcc/testsuite/g++.dg/reflect/parameters_of4.C
>index fe646e2f253..f0db631a961 100644
>--- a/gcc/testsuite/g++.dg/reflect/parameters_of4.C
>+++ b/gcc/testsuite/g++.dg/reflect/parameters_of4.C
>@@ -10,4 +10,4 @@ g ()
> {
> foo<std::meta::parameters_of(^^g)[0]>(); // { dg-error "no matching function for call to" }
> }
>-// { dg-error "call to non-'constexpr' function" "" { target *-*-* } 0 }
>+// { dg-error "call to non-'constexpr' function|contract predicate" "" { target *-*-* } 0 }
>diff --git a/gcc/testsuite/g++.dg/reflect/splicing-base4.C b/gcc/testsuite/g++.dg/reflect/splicing-base4.C
>index 1f9bd3d8199..63481f0a387 100644
>--- a/gcc/testsuite/g++.dg/reflect/splicing-base4.C
>+++ b/gcc/testsuite/g++.dg/reflect/splicing-base4.C
>@@ -25,4 +25,4 @@ g ()
> B &b2 = c.[: bases_of(^^D, uctx)[1] :]; // { dg-error "not a base type for type" }
> }
>
>-// { dg-error "call to non-.constexpr." "" { target *-*-* } 0 }
>+// { dg-error "call to non-.constexpr|contract predicate" "" { target *-*-* } 0 }
>diff --git a/libstdc++-v3/testsuite/20_util/constant_wrapper/type_param_neg.cc b/libstdc++-v3/testsuite/20_util/constant_wrapper/type_param_neg.cc
>index 1548e0789e1..b2122d0b934 100644
>--- a/libstdc++-v3/testsuite/20_util/constant_wrapper/type_param_neg.cc
>+++ b/libstdc++-v3/testsuite/20_util/constant_wrapper/type_param_neg.cc
>@@ -6,4 +6,5 @@ std::constant_wrapper<1.0, int> c2; // { dg-error "from here" }
> std::constant_wrapper<1, int const> c3; // { dg-error "from here" }
> std::constant_wrapper<1, int const&> c4; // { dg-error "from here" }
>
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion failed" }
>diff --git a/libstdc++-v3/testsuite/20_util/expected/illformed_neg.cc b/libstdc++-v3/testsuite/20_util/expected/illformed_neg.cc
>index 69aa4a17960..94873955acd 100644
>--- a/libstdc++-v3/testsuite/20_util/expected/illformed_neg.cc
>+++ b/libstdc++-v3/testsuite/20_util/expected/illformed_neg.cc
>@@ -65,4 +65,5 @@ test_expected_error()
> }
>
> // { dg-prune-output "static assertion failed" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "function returning an array" }
>diff --git a/libstdc++-v3/testsuite/20_util/function_ref/cons_neg.cc b/libstdc++-v3/testsuite/20_util/function_ref/cons_neg.cc
>index a426ac64cd5..cb154931468 100644
>--- a/libstdc++-v3/testsuite/20_util/function_ref/cons_neg.cc
>+++ b/libstdc++-v3/testsuite/20_util/function_ref/cons_neg.cc
>@@ -26,4 +26,5 @@ function_ref<int()> br6(std::cw<mfp>, s); // { dg-error "from here" }
> function_ref<int()> bp7(std::cw<mdp>, &s); // { dg-error "from here" }
> function_ref<int()> bp8(std::cw<mfp>, &s); // { dg-error "from here" }
>
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion failed" }
>diff --git a/libstdc++-v3/testsuite/20_util/function_ref/cw_cons_neg.cc b/libstdc++-v3/testsuite/20_util/function_ref/cw_cons_neg.cc
>index a295bc2ce31..9f1f7d7906f 100644
>--- a/libstdc++-v3/testsuite/20_util/function_ref/cw_cons_neg.cc
>+++ b/libstdc++-v3/testsuite/20_util/function_ref/cw_cons_neg.cc
>@@ -32,4 +32,5 @@ function_ref<int(int, int)> f2a(std::cw<S{}>); // OK, runtime
> function_ref<int(constant_wrapper<1>, int)> f2b(std::cw<S{}>); // OK, still runtime
> function_ref<int(constant_wrapper<2>, constant_wrapper<3>)> f2c(std::cw<S{}>); // { dg-error "from here" }
>
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion failed" }
>diff --git a/libstdc++-v3/testsuite/20_util/has_unique_object_representations/neg.cc b/libstdc++-v3/testsuite/20_util/has_unique_object_representations/neg.cc
>index 9654fb4b99a..6e68b5a00ee 100644
>--- a/libstdc++-v3/testsuite/20_util/has_unique_object_representations/neg.cc
>+++ b/libstdc++-v3/testsuite/20_util/has_unique_object_representations/neg.cc
>@@ -12,4 +12,5 @@ static_assert(std::has_unique_object_representations_v<Incomplete[]>); // {
> // { dg-prune-output "invalid use of incomplete type" }
> // { dg-prune-output "template argument must be a complete" }
> // { dg-prune-output "'value' is not a member of 'std::has_unique_object_representations" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion" }
>diff --git a/libstdc++-v3/testsuite/20_util/optional/monadic/or_else_neg.cc b/libstdc++-v3/testsuite/20_util/optional/monadic/or_else_neg.cc
>index 12a67bbc118..e672fb4ba35 100644
>--- a/libstdc++-v3/testsuite/20_util/optional/monadic/or_else_neg.cc
>+++ b/libstdc++-v3/testsuite/20_util/optional/monadic/or_else_neg.cc
>@@ -27,4 +27,5 @@ test02()
> std::optional<move_only> mo;
> mo.or_else([]{ return std::optional<move_only>{}; }); // { dg-error "no matching function" }
> // { dg-error "use of deleted function" "" { target *-*-* } 0 }
>+// { dg-prune-output "contract predicate is false" }
> }
>diff --git a/libstdc++-v3/testsuite/20_util/optional/monadic/ref_neg.cc b/libstdc++-v3/testsuite/20_util/optional/monadic/ref_neg.cc
>index ed1b42b1992..1cd3859178b 100644
>--- a/libstdc++-v3/testsuite/20_util/optional/monadic/ref_neg.cc
>+++ b/libstdc++-v3/testsuite/20_util/optional/monadic/ref_neg.cc
>@@ -17,4 +17,5 @@ void test()
>
> // { dg-prune-output "in a union may not have reference type" }
> // { dg-prune-output "static assertion failed" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "forming pointer to reference type" }
>diff --git a/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_args_neg.cc b/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_args_neg.cc
>index 6166c658c54..47996364961 100644
>--- a/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_args_neg.cc
>+++ b/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_args_neg.cc
>@@ -40,4 +40,5 @@ auto t3 = std::make_optional<const C&&>(10, 20); // { dg-error "no matching func
> // { dg-prune-output "cannot bind .* reference of type" }
> // { dg-prune-output "binding reference of type" }
> // { dg-prune-output "no matching function for call to 'std::optional" }
>+// { dg-prune-output "contract predicate is false" }
>
>diff --git a/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_lvalue_neg.cc b/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_lvalue_neg.cc
>index aed6791a3ff..111f2fbc887 100644
>--- a/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_lvalue_neg.cc
>+++ b/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_lvalue_neg.cc
>@@ -37,4 +37,5 @@ auto clr3 = std::make_optional<const C&&>(cs); // { dg-error "no matching functi
> // { dg-prune-output "forming pointer to reference type" }
> // { dg-prune-output "cannot bind .* reference of type" }
> // { dg-prune-output "binding reference of type" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "no matching function for call to `std::optional" }
>diff --git a/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_rvalue_neg.cc b/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_rvalue_neg.cc
>index 22f669ceb68..c8def350956 100644
>--- a/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_rvalue_neg.cc
>+++ b/libstdc++-v3/testsuite/20_util/optional/ref/make_optional/from_rvalue_neg.cc
>@@ -35,4 +35,5 @@ auto b4 = std::make_optional<const C&&>({10}); // { dg-error "no matching functi
> // { dg-prune-output "forming pointer to reference type" }
> // { dg-prune-output "cannot bind .* reference of type" }
> // { dg-prune-output "binding reference of type" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "no matching function for call to 'std::optional" }
>diff --git a/libstdc++-v3/testsuite/20_util/stdbit/2_neg.cc b/libstdc++-v3/testsuite/20_util/stdbit/2_neg.cc
>index d08fdaf139e..ee935899934 100644
>--- a/libstdc++-v3/testsuite/20_util/stdbit/2_neg.cc
>+++ b/libstdc++-v3/testsuite/20_util/stdbit/2_neg.cc
>@@ -42,4 +42,5 @@ test_mandates()
> // { dg-prune-output "no matching function" }
> // { dg-prune-output "wrong type" }
> // { dg-prune-output "invalid operands" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "non-integral type" }
>diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc
>index 159294f2b7b..a0b6dadc01b 100644
>--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc
>+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc
>@@ -31,4 +31,4 @@ back()
>
> static_assert(back() != 'a'); // { dg-error "non-constant condition" }
>
>-// { dg-error "assert_fail" "" { target *-*-* } 0 }
>+// { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
>diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc
>index 261d71be465..5a1172101df 100644
>--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc
>+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc
>@@ -28,6 +28,6 @@ test()
> return s[s.length()];
> }
>
>-static_assert(test() == 0); // { dg-error "non-constant condition" }
>+static_assert(test() == 0); // { dg-error "" }
>
>-// { dg-error "assert_fail" "" { target *-*-* } 0 }
>+// { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
>diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc
>index 5a98ff40688..e25857749ce 100644
>--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc
>+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc
>@@ -29,6 +29,6 @@ front()
> return s.front();
> }
>
>-static_assert(front() != 'a'); // { dg-error "non-constant condition" }
>+static_assert(front() != 'a'); // { dg-error "" }
>
>-// { dg-error "assert_fail" "" { target *-*-* } 0 }
>+// { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
>diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc
>index 288bada9776..afa6009838f 100644
>--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc
>+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc
>@@ -31,4 +31,4 @@ back()
>
> static_assert(back() != L'a'); // { dg-error "non-constant condition" }
>
>-// { dg-error "assert_fail" "" { target *-*-* } 0 }
>+// { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
>diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc
>index c6e823adbbc..b66d46f8005 100644
>--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc
>+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc
>@@ -28,6 +28,6 @@ test()
> return s[4];
> }
>
>-static_assert(test() == 0); // { dg-error "non-constant condition" }
>+static_assert(test() == 0); // { dg-error "" }
>
>-// { dg-error "assert_fail" "" { target *-*-* } 0 }
>+// { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
>diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc
>index 7e3255a4a7b..3d71072e8f7 100644
>--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc
>+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc
>@@ -29,6 +29,6 @@ front()
> return s.front();
> }
>
>-static_assert(front() != L'a'); // { dg-error "non-constant condition" }
>+static_assert(front() != L'a'); // { dg-error "" }
>
>-// { dg-error "assert_fail" "" { target *-*-* } 0 }
>+// { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
>diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/debug.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/debug.cc
>index 87a96600723..d1d411c493a 100644
>--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/debug.cc
>+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/debug.cc
>@@ -7,7 +7,7 @@ check_remove_prefix()
> {
> std::string_view sv("123");
> sv.remove_prefix(4);
>- // { dg-error "assert_fail" "" { target *-*-* } 0 }
>+ // { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
> return true;
> }
>
>diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/debug.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/debug.cc
>index 513aa8ce28a..552f993e558 100644
>--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/debug.cc
>+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/debug.cc
>@@ -7,7 +7,7 @@ check_remove_suffix()
> {
> std::string_view sv("123");
> sv.remove_suffix(4);
>- // { dg-error "assert_fail" "" { target *-*-* } 0 }
>+ // { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
> return true;
> }
>
>diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/traits_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/traits_neg.cc
>index e890c528de0..559074dd6a8 100644
>--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/traits_neg.cc
>+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/traits_neg.cc
>@@ -33,4 +33,5 @@
> std::basic_string_view<char, std::char_traits<char16_t>> s1; // { dg-error "here" }
> std::basic_string_view<char32_t, std::char_traits<char>> s2; // { dg-error "here" }
>
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion failed" }
>diff --git a/libstdc++-v3/testsuite/23_containers/array/creation/3_neg.cc b/libstdc++-v3/testsuite/23_containers/array/creation/3_neg.cc
>index 92080519233..942ce1b31e7 100644
>--- a/libstdc++-v3/testsuite/23_containers/array/creation/3_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/array/creation/3_neg.cc
>@@ -55,4 +55,5 @@ test03()
>
> // { dg-prune-output "static assertion failed" }
> // { dg-prune-output "use of deleted function" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "could not convert" }
>diff --git a/libstdc++-v3/testsuite/23_containers/array/element_access/constexpr_c++17.cc b/libstdc++-v3/testsuite/23_containers/array/element_access/constexpr_c++17.cc
>index 0df629e9f07..a160ba08f50 100644
>--- a/libstdc++-v3/testsuite/23_containers/array/element_access/constexpr_c++17.cc
>+++ b/libstdc++-v3/testsuite/23_containers/array/element_access/constexpr_c++17.cc
>@@ -110,3 +110,5 @@ template<typename T = int>
>
> static_assert( ! access_past_the_end() );
> #endif
>+
>+// { dg-prune-output "contract predicate is false" }
>diff --git a/libstdc++-v3/testsuite/23_containers/inplace_vector/access/elem_neg.cc b/libstdc++-v3/testsuite/23_containers/inplace_vector/access/elem_neg.cc
>index b2bff0d6387..83a7c130923 100644
>--- a/libstdc++-v3/testsuite/23_containers/inplace_vector/access/elem_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/inplace_vector/access/elem_neg.cc
>@@ -63,3 +63,4 @@ static_assert(test_out_of_size<true, int>()); // { dg-error "in 'constexp
> // { dg-prune-output "non-constant condition for static assertion" }
> // { dg-prune-output "is not a constant expression" }
> // { dg-prune-output "call to non-'constexpr' function" }
>+// { dg-prune-output "contract predicate is false" }
>diff --git a/libstdc++-v3/testsuite/23_containers/inplace_vector/modifiers/erase_neg.cc b/libstdc++-v3/testsuite/23_containers/inplace_vector/modifiers/erase_neg.cc
>index a1f43b3b53b..81f63ab6233 100644
>--- a/libstdc++-v3/testsuite/23_containers/inplace_vector/modifiers/erase_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/inplace_vector/modifiers/erase_neg.cc
>@@ -40,4 +40,5 @@ static_assert(test_erase_end<4, int>(4)); // { dg-error "in 'constexpr' expansio
>
> // { dg-prune-output "non-constant condition for static assertion" }
> // { dg-prune-output "is not a constant expression" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "call to non-'constexpr' function" }
>diff --git a/libstdc++-v3/testsuite/23_containers/inplace_vector/modifiers/single_insert_neg.cc b/libstdc++-v3/testsuite/23_containers/inplace_vector/modifiers/single_insert_neg.cc
>index 0552b8c2b7d..5820772f200 100644
>--- a/libstdc++-v3/testsuite/23_containers/inplace_vector/modifiers/single_insert_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/inplace_vector/modifiers/single_insert_neg.cc
>@@ -39,4 +39,5 @@ static_assert(test_push_back_rvalue<4, int>()); // { dg-error "in 'constexpr' ex
>
> // { dg-prune-output "non-constant condition for static assertion" }
> // { dg-prune-output "is not a constant expression" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "call to non-'constexpr' function" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/accessors/aligned_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/accessors/aligned_neg.cc
>index f36ebb17f83..c71493e76e5 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/accessors/aligned_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/accessors/aligned_neg.cc
>@@ -30,4 +30,5 @@ std::aligned_accessor<Abstract, alignof(int)> f_err; // { dg-error "required fro
> // { dg-prune-output "ByteAlignment must be a power of two" }
> // { dg-prune-output "ElementType must not be an array type" }
> // { dg-prune-output "ElementType must not be an abstract" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion failed" } // no message for alignment being too small
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/class_mandate_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/class_mandate_neg.cc
>index 172f149176f..8aa08a03c7d 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/class_mandate_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/class_mandate_neg.cc
>@@ -38,4 +38,5 @@ static_assert(test_element_type_mismatch());
> // { dg-prune-output "no type named '_Storage'" }
> // { dg-prune-output "non-constant condition" }
> // { dg-prune-output "static assertion failed" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "__glibcxx_assert" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/extents/class_mandates_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/extents/class_mandates_neg.cc
>index db5cad27e52..6be5f12813b 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/extents/class_mandates_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/extents/class_mandates_neg.cc
>@@ -14,4 +14,5 @@ std::extents<double, 1> e4; // { dg-error "from here" }
> // { dg-prune-output "non-constant condition for static assertion" }
> // { dg-prune-output "integer constants in boolean context" }
> // { dg-prune-output "__gnu_cxx::__numeric_traits_integer" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion failed" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/extents/extents_mismatch_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/extents/extents_mismatch_neg.cc
>index b35e5310d41..46dccd7f2b3 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/extents/extents_mismatch_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/extents/extents_mismatch_neg.cc
>@@ -32,4 +32,5 @@ test_dyn2sta_extents_mismatch_02()
> static_assert(test_dyn2sta_extents_mismatch_02()); // { dg-error "expansion of" }
>
> // { dg-prune-output "non-constant condition for static assertion" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "__glibcxx_assert" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc
>index edf07c983da..a89190350ab 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc
>@@ -46,4 +46,5 @@ auto b6 = B<6, std::layout_stride, std::layout_left>(); // { dg-error "require
> auto b7 = B<7, std::layout_stride, std::layout_stride>(); // { dg-error "required from" }
>
> // { dg-prune-output "must be representable as index_type" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion failed" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/debug/out_of_bounds_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/debug/out_of_bounds_neg.cc
>index fb8ff01e8aa..c7b8b0acc78 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/debug/out_of_bounds_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/debug/out_of_bounds_neg.cc
>@@ -27,4 +27,5 @@ static_assert(test_out_of_bounds_3d<std::layout_right>()); // { dg-error "expans
> static_assert(test_out_of_bounds_3d<std::layout_stride>()); // { dg-error "expansion of" }
>
> // { dg-prune-output "non-constant condition for static assertion" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "__glibcxx_assert" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/padded_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/padded_neg.cc
>index 36d61179cf8..8aa9a1288df 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/padded_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/padded_neg.cc
>@@ -349,4 +349,5 @@ static_assert(test_statically_oversized<std::layout_right_padded>()); // { dg-er
> // { dg-prune-output "__glibcxx_assert_fail()" }
> // { dg-prune-output "must be compatible with other.stride" }
> // { dg-prune-output "padding_value is dynamic_extent" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "_S_rank <= 1" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/stride_debug_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/stride_debug_neg.cc
>index bc5f41489d7..9535315d24c 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/stride_debug_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/stride_debug_neg.cc
>@@ -39,4 +39,5 @@ constexpr auto m48 = mapping<4>(array{2, 3, 5, 4}, array{5, 2, 10, 50}); // { dg
> constexpr auto m49 = mapping<4>(array{2, 1, 3, 5}, array{5, 99, 2, 10}); // { dg-bogus "expansion of" }
>
> // { dg-prune-output "non-constant condition for static assertion" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "__glibcxx_assert_fail()" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/stride_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/stride_neg.cc
>index 5a818042b5a..4d822ffba6a 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/stride_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/stride_neg.cc
>@@ -83,4 +83,5 @@ constexpr auto m2d = mapping<5>(array{3, 4, 1, 1, 5}, array{3, 10, 00, 99, 45});
> constexpr auto m2e = mapping<5>(array{1, 1, 1, 1, 1}, array{00, 77, 88, 99, 00}); // { dg-bogus "expansion of" }
>
> // { dg-prune-output "non-constant condition for static assertion" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "__glibcxx_assert_fail()" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/out_of_bounds_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/out_of_bounds_neg.cc
>index dceae56e9d9..9d4160354d3 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/out_of_bounds_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/out_of_bounds_neg.cc
>@@ -21,4 +21,5 @@ static_assert(test_invalid_multi_index<std::layout_right>()); // { dg-error "exp
> static_assert(test_invalid_multi_index<std::layout_stride>()); // { dg-error "expansion of" }
>
> // { dg-prune-output "non-constant condition" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "__glibcxx_assert" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/canonical_slices_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/canonical_slices_neg.cc
>index c1ff4275cbd..068e348c2b6 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/canonical_slices_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/canonical_slices_neg.cc
>@@ -238,4 +238,5 @@ static_assert(test_invalid(std::cw<3>, std::cw<0>)); // { dg-error "expansion of
> // { dg-prune-output "static assertion failed" }
> // { dg-prune-output "__glibcxx_assert_fail" }
> // { dg-prune-output "__glibcxx_assert" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "non-constant condition" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/extent_slice_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/extent_slice_neg.cc
>index 9740b37668a..64045ced73b 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/extent_slice_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/extent_slice_neg.cc
>@@ -16,4 +16,5 @@ static_assert(test_invalid<int, double, int>()); // { dg-error "required from" }
> static_assert(test_invalid<int, int, double>()); // { dg-error "required from" }
> static_assert(test_invalid<double, double, double>()); // { dg-error "required from" }
>
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion failed" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/subextents_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/subextents_neg.cc
>index 2ff419ec50c..07e4524d534 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/subextents_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/subextents_neg.cc
>@@ -45,4 +45,5 @@ static_assert(test_out_of_bounds(std::tuple{-1, 2})); // { dg-error "
> // { dg-prune-output "cannot decompose class type 'NotASlice'" }
> // { dg-prune-output "static assertion failed" }
> // { dg-prune-output "__glibcxx_assert_fail" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "non-constant condition" }
>diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_neg.cc b/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_neg.cc
>index 8e673a08433..65c976a84bb 100644
>--- a/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_neg.cc
>@@ -119,4 +119,5 @@ static_assert(test_extent_slice_extent_over<std::layout_stride>()); // { dg-erro
> // { dg-prune-output "__glibcxx_assert_fail" }
> // { dg-prune-output "non-constant condition" }
> // { dg-prune-output "no matching function" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "does not satisfy placeholder constraints" }
>diff --git a/libstdc++-v3/testsuite/23_containers/span/back_neg.cc b/libstdc++-v3/testsuite/23_containers/span/back_neg.cc
>index b1ee7ed58d4..b8237d2b064 100644
>--- a/libstdc++-v3/testsuite/23_containers/span/back_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/span/back_neg.cc
>@@ -30,5 +30,5 @@ test01(bool b)
>
> static_assert(test01(false));
> static_assert(test01(true)); // { dg-error "non-constant" }
>-// { dg-error "assert_fail" "" { target *-*-* } 0 }
>+// { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
> // { dg-prune-output "called in a constant expression" }
>diff --git a/libstdc++-v3/testsuite/23_containers/span/front_neg.cc b/libstdc++-v3/testsuite/23_containers/span/front_neg.cc
>index b9bfc9d8ce4..e0858a0760e 100644
>--- a/libstdc++-v3/testsuite/23_containers/span/front_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/span/front_neg.cc
>@@ -30,5 +30,5 @@ test01(bool b)
>
> static_assert(test01(false));
> static_assert(test01(true)); // { dg-error "non-constant" }
>-// { dg-error "assert_fail" "" { target *-*-* } 0 }
>+// { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
> // { dg-prune-output "called in a constant expression" }
>diff --git a/libstdc++-v3/testsuite/23_containers/span/index_op_neg.cc b/libstdc++-v3/testsuite/23_containers/span/index_op_neg.cc
>index a1217b9bbe4..7c26b4978ae 100644
>--- a/libstdc++-v3/testsuite/23_containers/span/index_op_neg.cc
>+++ b/libstdc++-v3/testsuite/23_containers/span/index_op_neg.cc
>@@ -30,5 +30,5 @@ test01(bool b)
>
> static_assert(test01(false));
> static_assert(test01(true)); // { dg-error "non-constant" }
>-// { dg-error "assert_fail" "" { target *-*-* } 0 }
>+// { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
> // { dg-prune-output "called in a constant expression" }
>diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/element_access/constexpr.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/element_access/constexpr.cc
>index 7c60e5db4d1..14be17f5b9c 100644
>--- a/libstdc++-v3/testsuite/23_containers/vector/bool/element_access/constexpr.cc
>+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/element_access/constexpr.cc
>@@ -116,3 +116,5 @@ template<typename T = bool>
> access_empty_front() { return {}; }
>
> static_assert( ! access_empty_front() );
>+
>+// { dg-prune-output "contract predicate is false" }
>diff --git a/libstdc++-v3/testsuite/23_containers/vector/element_access/constexpr.cc b/libstdc++-v3/testsuite/23_containers/vector/element_access/constexpr.cc
>index 358ded47ad9..00029ebee39 100644
>--- a/libstdc++-v3/testsuite/23_containers/vector/element_access/constexpr.cc
>+++ b/libstdc++-v3/testsuite/23_containers/vector/element_access/constexpr.cc
>@@ -121,3 +121,5 @@ template<typename T = int>
> access_past_the_end() { return {}; }
>
> static_assert( ! access_past_the_end() );
>+
>+// { dg-prune-output "contract predicate is false" }
>diff --git a/libstdc++-v3/testsuite/25_algorithms/clamp/118185.cc b/libstdc++-v3/testsuite/25_algorithms/clamp/118185.cc
>index e9cf896d355..4482141b6c1 100644
>--- a/libstdc++-v3/testsuite/25_algorithms/clamp/118185.cc
>+++ b/libstdc++-v3/testsuite/25_algorithms/clamp/118185.cc
>@@ -5,7 +5,7 @@
>
> struct Comp
> {
>- constexpr bool operator()(const int&& x, const int&& y) { return x < y; }
>+ constexpr bool operator()(const int&& x, const int&& y) const { return x < y; }
> };
>
> struct Proj
>diff --git a/libstdc++-v3/testsuite/26_numerics/lcm/105844.cc b/libstdc++-v3/testsuite/26_numerics/lcm/105844.cc
>index 65a999c3e05..98534262a29 100644
>--- a/libstdc++-v3/testsuite/26_numerics/lcm/105844.cc
>+++ b/libstdc++-v3/testsuite/26_numerics/lcm/105844.cc
>@@ -21,4 +21,4 @@ constexpr int e = std::lcm(500000u, 499999); // { dg-error "in .constexpr." }
> constexpr int f = std::lcm(499999u, 500000); // { dg-error "in .constexpr." }
>
> // { dg-error "overflow" "" { target *-*-* } 0 }
>-// { dg-error "assert_fail" "" { target *-*-* } 0 }
>+// { dg-error "assert_fail|contract" "" { target *-*-* } 0 }
>diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/input_type_fallback_neg.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/input_type_fallback_neg.cc
>index 3dfba49d7f9..f74a893247d 100644
>--- a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/input_type_fallback_neg.cc
>+++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/input_type_fallback_neg.cc
>@@ -52,4 +52,5 @@ int main()
> test<long double>(); // { dg-error "here" }
> }
>
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion failed" }
>diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/input_type_fallback_neg.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/input_type_fallback_neg.cc
>index 4bc9ca2704e..8b2833c1437 100644
>--- a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/input_type_fallback_neg.cc
>+++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/input_type_fallback_neg.cc
>@@ -52,4 +52,5 @@ int main()
> test<long double>(); // { dg-error "here" }
> }
>
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion failed" }
>diff --git a/libstdc++-v3/testsuite/26_numerics/stdckdint/2_neg.cc b/libstdc++-v3/testsuite/26_numerics/stdckdint/2_neg.cc
>index 7954da2d0d9..297ca48b8bf 100644
>--- a/libstdc++-v3/testsuite/26_numerics/stdckdint/2_neg.cc
>+++ b/libstdc++-v3/testsuite/26_numerics/stdckdint/2_neg.cc
>@@ -36,4 +36,5 @@ test_mul(int i, char c, bool b)
> }
>
> // { dg-prune-output "static assertion failed" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "pointer to 'const'" }
>diff --git a/libstdc++-v3/testsuite/30_threads/semaphore/cons_neg.cc b/libstdc++-v3/testsuite/30_threads/semaphore/cons_neg.cc
>index 56e27d7ddc4..13b1c5dcfff 100644
>--- a/libstdc++-v3/testsuite/30_threads/semaphore/cons_neg.cc
>+++ b/libstdc++-v3/testsuite/30_threads/semaphore/cons_neg.cc
>@@ -10,3 +10,5 @@ int main()
> // Preconditions: desired >= 0 is true, and desired <= max() is true.
> std::binary_semaphore b(2);
> }
>+
>+// { dg-prune-output "contract predicate is false" }
>diff --git a/libstdc++-v3/testsuite/std/memory/start_lifetime_as/neg.cc b/libstdc++-v3/testsuite/std/memory/start_lifetime_as/neg.cc
>index 0eeed67be48..9335a0db6f0 100644
>--- a/libstdc++-v3/testsuite/std/memory/start_lifetime_as/neg.cc
>+++ b/libstdc++-v3/testsuite/std/memory/start_lifetime_as/neg.cc
>@@ -42,4 +42,5 @@ void test(void* p)
>
> // { dg-prune-output "incomplete type" }
> // { dg-prune-output "template argument must be a complete type" }
>+// { dg-prune-output "contract predicate is false" }
> // { dg-prune-output "static assertion" }
>diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp
>index 90151b07b69..ba9846ed7db 100644
>--- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp
>+++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp
>@@ -114,7 +114,7 @@ rotate_parent(node_pointer p_nd)
> else
> rotate_left(p_parent);
>
>- _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd);
>+ _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent == p_nd);
> _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent ||
> p_nd->m_p_right == p_parent);
> }
>diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp
>index 769a35231f1..463692f6aca 100644
>--- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp
>+++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp
>@@ -45,7 +45,7 @@ inline void
> PB_DS_CLASS_C_DEC::
> erase_entry(entry_pointer p_e)
> {
>- _GLIBCXX_DEBUG_ASSERT(p_e->m_stat = valid_entry_status);
>+ _GLIBCXX_DEBUG_ASSERT(p_e->m_stat == valid_entry_status);
> _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_e->m_value));)
> p_e->m_value.~value_type();
> p_e->m_stat = erased_entry_status;
>diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp
>index ffe5c22d34d..404cce6a163 100644
>--- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp
>+++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp
>@@ -108,7 +108,7 @@ rotate_parent(node_pointer p_nd)
> rotate_right(p_parent);
> else
> rotate_left(p_parent);
>- _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd);
>+ _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent == p_nd);
> _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent || p_nd->m_p_right == p_parent);
> }
>
>diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
>index 0c2407ccd07..fa219b33690 100644
>--- a/libstdc++-v3/include/bits/c++config
>+++ b/libstdc++-v3/include/bits/c++config
>@@ -642,15 +642,26 @@ namespace std
> #if defined(_GLIBCXX_ASSERTIONS)
> // When _GLIBCXX_ASSERTIONS is defined we enable runtime assertion checks.
> // These checks will also be done during constant evaluation.
>+# if __cpp_contracts
>+# define __glibcxx_assert(cond) __contract_assert(cond)
>+# else
> # define __glibcxx_assert(cond) \
> do { \
> if (__builtin_expect(!bool(cond), false)) \
> _GLIBCXX_ASSERT_FAIL(cond); \
> } while (false)
>+# endif
> #elif _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
> // _GLIBCXX_ASSERTIONS is not defined, so assertions checks are only enabled
> // during constant evaluation. This ensures we diagnose undefined behaviour
> // in constant expressions.
>+# if __cpp_contracts
>+# define __glibcxx_assert(cond) \
>+ do { \
>+ if (std::__is_constant_evaluated()) \
>+ __contract_assert (cond); \
No space before the paren in libstdc++ code :-)
>+ } while (false)
>+# else
> namespace std
> {
> __attribute__((__always_inline__,__visibility__("default")))
>@@ -663,6 +674,7 @@ namespace std
> if (std::__is_constant_evaluated() && !bool(cond)) \
> std::__glibcxx_assert_fail(); \
> } while (false)
>+# endif
> #else
> // _GLIBCXX_ASSERTIONS is not defined and __is_constant_evaluated() doesn't
> // work so don't check any assertions.
>
>base-commit: e9ac6f861c459436695874617244a0fbd118ea78
>--
>2.56.0
>
>
More information about the Libstdc++
mailing list