libstdc++: Always return a sentinel<I> from __gnu_test::test_range::end()
authorPatrick Palka <ppalka@redhat.com>
Tue, 21 Jan 2020 22:00:43 +0000 (17:00 -0500)
committerPatrick Palka <ppalka@redhat.com>
Fri, 31 Jan 2020 17:17:10 +0000 (12:17 -0500)
commit6e5a196399d4393f30f2617f6fc042f2e94730b0
tree5a02ad819e4c2b3bcfa4184195b80398c4a3da18
parentb92709388b9aee52db3cd7c227818e0ecccda2e5
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 container 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 range more strict by having end() unconditionally return a
sentinel<I>, and adjust some tests accordingly.

libstdc++-v3/ChangeLog:

* testsuite/24_iterators/range_operations/distance.cc: Do not assume
test_range::end() returns the same type as test_range::begin().
* testsuite/24_iterators/range_operations/next.cc: Likewise.
* testsuite/24_iterators/range_operations/prev.cc: Likewise.
* testsuite/util/testsuite_iterators.h (__gnu_test::test_range::end):
Always return a sentinel<I>.
libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/24_iterators/range_operations/distance.cc
libstdc++-v3/testsuite/24_iterators/range_operations/next.cc
libstdc++-v3/testsuite/24_iterators/range_operations/prev.cc
libstdc++-v3/testsuite/util/testsuite_iterators.h