Commit ae705159 by Jonathan Wakely

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.
parent b112e3cb
2020-02-27 Jonathan Wakely <jwakely@redhat.com>
* 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.
* testsuite/23_containers/span/back_assert_neg.cc: Add #undef before
defining _GLIBCXX_ASSERTIONS.
* testsuite/23_containers/span/first_2_assert_neg.cc: Likewise.
......
......@@ -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.
......
......@@ -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 }
......@@ -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 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment