]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Avoid hard error in ranges::unique_copy [PR100770]
authorPatrick Palka <ppalka@redhat.com>
Thu, 3 Jun 2021 16:30:29 +0000 (12:30 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 3 Jun 2021 16:30:29 +0000 (12:30 -0400)
commit0614bbbe59c6953e088cffa39dfe63d86fc1fa96
tree3b848e0660f4e2765f2b095d74ce85160426b1e4
parentcd4dd47265f2bff89fbbfb6a12a98a7101fb5280
libstdc++: Avoid hard error in ranges::unique_copy [PR100770]

Here, in the constexpr if condition within ranges::unique_copy, when
input_iterator<_Out> isn't satisfied we must avoid substituting into
iter_value_t<_Out> because the latter isn't necessarily well-formed
then.  To that end, this patch factors out the condition into a concept
and uses it throughout.

This patch also makes the definition of our testsuite
output_iterator_wrapper more minimal by setting its value_type, pointer
and reference member types to void.  This means our existing tests for
unique_copy already exercise the fix for this bug, so we don't need
to add another test.  The only other fallout of this testsuite iterator
change appears in std/ranges/range.cc, where the use of range_value_t
on a test_output_range is now ill-formed.

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__detail::__can_reread_output):
Factor out this concept from ...
(__unique_copy_fn::operator()): ... here.  Use the concept
throughout.
* testsuite/std/ranges/range.cc: Remove now ill-formed use
of range_value_t on an output_range.
* testsuite/util/testsuite_iterators.h (output_iterator_wrapper):
Define value_type, pointer and reference member types to void.
libstdc++-v3/include/bits/ranges_algo.h
libstdc++-v3/testsuite/std/ranges/range.cc
libstdc++-v3/testsuite/util/testsuite_iterators.h