[Bug libstdc++/100479] range adaptors handle cached iterators incorrectly
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon May 24 19:24:53 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100479
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:46ed811bcb4b86a81ef3d78ea8cfffc6cd043144
commit r12-1018-g46ed811bcb4b86a81ef3d78ea8cfffc6cd043144
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon May 24 15:24:44 2021 -0400
libstdc++: Fix iterator caching inside range adaptors [PR100479]
This fixes two issues with our iterator caching as described in detail
in the PR. Since we recently added the __non_propagating_cache class
template as part of r12-336 for P2328, this patch just rewrites the
problematic _CachedPosition partial specialization in terms of this
class template.
For the offset partial specialization, it's safe to propagate the cached
offset on copy/move, but we should still invalidate the cached offset in
the source object on move.
libstdc++-v3/ChangeLog:
PR libstdc++/100479
* include/std/ranges (__detail::__non_propagating_cache): Move
definition up to before that of _CachedPosition. Make base
class _Optional_base protected instead of private. Add const
overload for operator*.
(__detail::_CachedPosition): Rewrite the partial specialization
for forward ranges as a derived class of __non_propagating_cache.
Remove the size constraint on the partial specialization for
random access ranges. Add
copy/move/copy-assignment/move-assignment
members to the offset partial specialization for random
access ranges that propagate the cached value but additionally
invalidate it in the source object on move.
* testsuite/std/ranges/adaptors/100479.cc: New test.
More information about the Gcc-bugs
mailing list