Three fixes for test failures when debug mode is enabled.
Tested x86_64-linux, committed to master.
commit ae7051590d4bf9b844874e727791f236315c835a Author: Jonathan Wakely <jwak...@redhat.com> Date: Thu Feb 27 15:13:16 2020 +0000 libstdc++: Define <=> for Debug Mode array This fixes a test failure with -D_GLIBCXX_DEBUG: FAIL: 23_containers/array/comparison_operators/constexpr.cc (test for excess errors) * include/debug/array (operator<=>): Define for C++20. * testsuite/23_containers/array/tuple_interface/get_debug_neg.cc: Adjust dg-error line numbers. * testsuite/23_containers/array/tuple_interface/ tuple_element_debug_neg.cc: Likewise. diff --git a/libstdc++-v3/include/debug/array b/libstdc++-v3/include/debug/array index 3f87e98fe8d..dd4044c9c7b 100644 --- a/libstdc++-v3/include/debug/array +++ b/libstdc++-v3/include/debug/array @@ -239,6 +239,25 @@ namespace __debug operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return std::equal(__one.begin(), __one.end(), __two.begin()); } +#if __cpp_lib_three_way_comparison && __cpp_lib_concepts + template<typename _Tp, size_t _Nm> + constexpr __detail::__synth3way_t<_Tp> + operator<=>(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) + { + if constexpr (_Nm && __is_byte<_Tp>::__value) + return __builtin_memcmp(__a.data(), __b.data(), _Nm) <=> 0; + else + { + for (size_t __i = 0; __i < _Nm; ++__i) + { + auto __c = __detail::__synth3way(__a[__i], __b[__i]); + if (__c != 0) + return __c; + } + } + return strong_ordering::equal; + } +#else template<typename _Tp, std::size_t _Nm> _GLIBCXX20_CONSTEXPR inline bool @@ -271,6 +290,7 @@ namespace __debug inline bool operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one < __two); } +#endif // three_way_comparison && concepts // Specialized algorithms. diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc index 2736d060aed..0a9525e9654 100644 --- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc @@ -27,6 +27,6 @@ int n1 = std::get<1>(a); int n2 = std::get<1>(std::move(a)); int n3 = std::get<1>(ca); -// { dg-error "static assertion failed" "" { target *-*-* } 295 } -// { dg-error "static assertion failed" "" { target *-*-* } 304 } -// { dg-error "static assertion failed" "" { target *-*-* } 312 } +// { dg-error "static assertion failed" "" { target *-*-* } 315 } +// { dg-error "static assertion failed" "" { target *-*-* } 324 } +// { dg-error "static assertion failed" "" { target *-*-* } 332 } diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc index bca290b3625..0bd5989c04a 100644 --- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc @@ -22,4 +22,4 @@ typedef std::tuple_element<1, std::array<int, 1>>::type type; -// { dg-error "static assertion failed" "" { target *-*-* } 377 } +// { dg-error "static assertion failed" "" { target *-*-* } 397 } commit b112e3cb6025938ef9d8568d318e23e44c0c8fdd Author: Jonathan Wakely <jwak...@redhat.com> Date: Thu Feb 27 15:13:16 2020 +0000 libstdc++: Fix std::span test failures with _GLIBCXX_ASSERTIONS This fixes several failures with -D_GLIBCXX_ASSERTIONS added to the testsuite flags, such as: FAIL: 23_containers/span/back_assert_neg.cc (test for excess errors) * testsuite/23_containers/span/back_assert_neg.cc: Add #undef before defining _GLIBCXX_ASSERTIONS. * testsuite/23_containers/span/first_2_assert_neg.cc: Likewise. * testsuite/23_containers/span/first_assert_neg.cc: Likewise. * testsuite/23_containers/span/front_assert_neg.cc: Likewise. * testsuite/23_containers/span/index_op_assert_neg.cc: Likewise. * testsuite/23_containers/span/last_2_assert_neg.cc: Likewise. * testsuite/23_containers/span/last_assert_neg.cc: Likewise. * testsuite/23_containers/span/subspan_2_assert_neg.cc: Likewise. * testsuite/23_containers/span/subspan_3_assert_neg.cc: Likewise. * testsuite/23_containers/span/subspan_4_assert_neg.cc: Likewise. * testsuite/23_containers/span/subspan_5_assert_neg.cc: Likewise. * testsuite/23_containers/span/subspan_6_assert_neg.cc: Likewise. * testsuite/23_containers/span/subspan_assert_neg.cc: Likewise. diff --git a/libstdc++-v3/testsuite/23_containers/span/back_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/back_assert_neg.cc index f3f2b20851a..76f2a7eb286 100644 --- a/libstdc++-v3/testsuite/23_containers/span/back_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/back_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/first_2_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/first_2_assert_neg.cc index 7b202bdb997..0019fca5b8b 100644 --- a/libstdc++-v3/testsuite/23_containers/span/first_2_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/first_2_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/first_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/first_assert_neg.cc index e10184e04da..7b93abc9a92 100644 --- a/libstdc++-v3/testsuite/23_containers/span/first_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/first_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/front_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/front_assert_neg.cc index ea99c8b60b8..62dec39c6a0 100644 --- a/libstdc++-v3/testsuite/23_containers/span/front_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/front_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/index_op_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/index_op_assert_neg.cc index 4676b7a83e8..10432ebe72f 100644 --- a/libstdc++-v3/testsuite/23_containers/span/index_op_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/index_op_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/last_2_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/last_2_assert_neg.cc index fca1cedcc74..cc12c1f540e 100644 --- a/libstdc++-v3/testsuite/23_containers/span/last_2_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/last_2_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/last_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/last_assert_neg.cc index f831c72a77b..773bea49e57 100644 --- a/libstdc++-v3/testsuite/23_containers/span/last_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/last_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/subspan_2_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/subspan_2_assert_neg.cc index 00a94009dc5..a3b856ecd67 100644 --- a/libstdc++-v3/testsuite/23_containers/span/subspan_2_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/subspan_2_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/subspan_3_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/subspan_3_assert_neg.cc index c8a5c92e61f..2c559427094 100644 --- a/libstdc++-v3/testsuite/23_containers/span/subspan_3_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/subspan_3_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/subspan_4_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/subspan_4_assert_neg.cc index 1ccd5f2db67..8a082633bf1 100644 --- a/libstdc++-v3/testsuite/23_containers/span/subspan_4_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/subspan_4_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/subspan_5_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/subspan_5_assert_neg.cc index 685096df077..c3836478b66 100644 --- a/libstdc++-v3/testsuite/23_containers/span/subspan_5_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/subspan_5_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/subspan_6_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/subspan_6_assert_neg.cc index 2752aa254c6..a58d763ea9d 100644 --- a/libstdc++-v3/testsuite/23_containers/span/subspan_6_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/subspan_6_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> diff --git a/libstdc++-v3/testsuite/23_containers/span/subspan_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/subspan_assert_neg.cc index 56a91ab34ac..9160489382a 100644 --- a/libstdc++-v3/testsuite/23_containers/span/subspan_assert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/span/subspan_assert_neg.cc @@ -18,6 +18,7 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { xfail c++2a } } +#undef _GLIBCXX_ASSERTIONS #define _GLIBCXX_ASSERTIONS #include <span> commit f32a3662cda0492c7d18f32e9a8eac1054e69d62 Author: Jonathan Wakely <jwak...@redhat.com> Date: Thu Feb 27 15:13:16 2020 +0000 libstdc++: Fix std::string error in Debug Mode This fixes a test failure with -std=gnu++98 -D_GLIBCXX_DEBUG: FAIL: 21_strings/basic_string/modifiers/insert/char/1.cc (test for excess errors) * include/debug/string (__gnu_debug::basic_string::insert): Fix for C++98 where the member function of the base class returns void. diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string index 6615b08ba6d..1431ebafeba 100644 --- a/libstdc++-v3/include/debug/string +++ b/libstdc++-v3/include/debug/string @@ -635,7 +635,7 @@ namespace __gnu_debug __glibcxx_check_insert_range(__p, __first, __last, __dist); typename _Base::iterator __res; -#if _GLIBCXX_USE_CXX11_ABI +#if _GLIBCXX_USE_CXX11_ABI && __cplusplus >= 201103 if (__dist.second >= __dp_sign) __res = _Base::insert(__p.base(), __gnu_debug::__unsafe(__first), __gnu_debug::__unsafe(__last));