gcc/libstdc++-v3/testsuite
Jonathan Wakely a88fc03ba7 libstdc++: Remove precondition checks from ranges::subrange
The assertion in the subrange constructor causes semantic changes,
because the call to ranges::distance performs additional operations that
are not part of the constructor's specification. That will fail to
compile if the iterator is move-only, because the argument to
ranges::distance is passed by value. It will modify the subrange if the
iterator is not a forward iterator, because incrementing the copy also
affects the _M_begin member. Those problems could be prevented by using
if-constexpr to only do the assertion for copyable forward iterators,
but the call to ranges::distance can also prevent the constructor being
usable in constant expressions. If the member initializers are usable in
constant expressions, but iterator increments of equality comparisons
are not, then the checks done by __glibcxx_assert might
make constant evaluation fail.

This change removes the assertion. Additionally, a new typedef is
introduced to simplify the declarations using __make_unsigned_like_t on
the iterator's difference type.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (subrange): Add __size_type typedef
	and use it to simplify declarations.
	(subrange(i, s, n)): Remove assertion.
	* testsuite/std/ranges/subrange/constexpr.cc: New test.
2021-06-15 18:20:06 +01:00
..
17_intro libstdc++: Add explicit -std=gnu++17 option to test 2021-06-14 14:04:45 +01:00
18_support libstdc++: Implement LWG 3465 for std::compare_partial_order_fallback [PR101056] 2021-06-14 14:04:45 +01:00
19_diagnostics libstdc++: Remove redundant -std=gnu++17 option from remaining tests 2021-05-10 16:22:54 +01:00
20_util libstdc++: Fix common_reference for non-reference results [PR100894] 2021-06-14 21:17:53 +01:00
21_strings libstdc++: Use __builtin_unreachable for constexpr assertions [PR 100676] 2021-05-20 20:49:57 +01:00
22_locale libstdc++: Fix new test for C++98 mode [PR 89728] 2021-06-01 19:02:42 +01:00
23_containers libstdc++: Add feature test macro for heterogeneous lookup in unordered containers 2021-06-04 15:59:37 +01:00
24_iterators libstdc++: Fix return value of std::ranges::advance [PR 100833] 2021-06-01 17:09:06 +01:00
25_algorithms libstdc++: Qualify functions used in tests 2021-05-24 18:42:09 +01:00
26_numerics libstdc++: Remove redundant -std=gnu++17 option from remaining tests 2021-05-10 16:22:54 +01:00
27_io libstdc++: Fix filesystem::path comparisons for C++23 2021-06-11 19:18:11 +01:00
28_regex libstdc++: Remove redundant -std=gnu++17 option from remaining tests 2021-05-10 16:22:54 +01:00
29_atomics libstd++: Only support atomic_ref::wait tests which are always lockfree 2021-06-09 13:46:03 -07:00
30_threads libstdc++: Fix std::jthread assertion and re-enable skipped test 2021-05-17 17:56:57 +01:00
abi Update copyright years. 2021-01-04 10:26:59 +01:00
backward Update copyright years. 2021-01-04 10:26:59 +01:00
config Update copyright years. 2021-01-04 10:26:59 +01:00
data
decimal Update copyright years. 2021-01-04 10:26:59 +01:00
experimental libstdc++: Only run Filesystem TS test if supported 2021-06-14 15:10:56 +01:00
ext libstdc++: Suppress more vstring testsuite warnings. [PR 98613] 2021-01-10 18:22:51 -05:00
lib Add 'dg-note', 'dg-lto-note' 2021-05-18 12:39:57 +02:00
libstdc++-abi Update copyright years. 2021-01-04 10:26:59 +01:00
libstdc++-dg libstdc++: Add std::experimental::simd from the Parallelism TS 2 2021-01-27 16:37:26 +00:00
libstdc++-prettyprinters libstdc++: Remove redundant -std=gnu++17 option from remaining tests 2021-05-10 16:22:54 +01:00
libstdc++-xmethods Update copyright years. 2021-01-04 10:26:59 +01:00
performance Update copyright years. 2021-01-04 10:26:59 +01:00
special_functions Update copyright years. 2021-01-04 10:26:59 +01:00
std libstdc++: Remove precondition checks from ranges::subrange 2021-06-15 18:20:06 +01:00
tr1 libstdc++: Fix some tests that fail in C++20 mode 2021-04-12 12:30:07 +01:00
tr2 Update copyright years. 2021-01-04 10:26:59 +01:00
util libstdc++: Avoid hard error in ranges::unique_copy [PR100770] 2021-06-03 12:30:29 -04:00
Makefile.am libstdc++: Work around test failures using -mno-tree-vrp 2021-02-03 15:49:30 +00:00
Makefile.in libstdc++: Work around test failures using -mno-tree-vrp 2021-02-03 15:49:30 +00:00