[gcc(refs/users/ppalka/heads/libstdcxx-constrained-algos)] libstdc++: Always return a sentinel<I> from __gnu_test::test_range::end()

Patrick Palka ppalka@gcc.gnu.org
Wed Jan 22 16:52:00 GMT 2020


commit a9c9d1939637f6d03b63e17a23da2a51c563da8d
Author: Patrick Palka <ppalka@gcc.gnu.org>
Date:   Tue Jan 21 17:00:43 2020 -0500

    libstdc++: Always return a sentinel<I> from __gnu_test::test_range::end()
    It seems that in practice std::sentinel_for<I, I> is always true, and so the
    test_range range doesn't help us detect bugs in ranges code in which we wrongly
    assume that a sentinel can be manipulated like an iterator.  Make the test_range
    container more strict by having end() unconditionally return a sentinel<I>.
    	* testsuite/util/testsuite_iterators.h (__gnu_test::test_range::end):
    	Always return a sentinel<I>.

 libstdc++-v3/testsuite/util/testsuite_iterators.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h
index eb15257..6667a3a 100644
--- a/libstdc++-v3/testsuite/util/testsuite_iterators.h
+++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h
@@ -702,10 +702,7 @@ namespace __gnu_test
       auto end() &
 	using I = decltype(get_iterator(bounds.last));
-	if constexpr (std::sentinel_for<I, I>)
-	  return get_iterator(bounds.last);
-	else
-	  return sentinel<I>{bounds.last};
+	return sentinel<I>{bounds.last};
       typename Iter<T>::ContainerType bounds;

More information about the Libstdc++-cvs mailing list