[Bug libstdc++/94354] std::reverse_iterator comparison operators defined incorrectly
cvs-commit at gcc dot gnu.org
Wed May 27 20:59:24 GMT 2020
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <firstname.lastname@example.org>:
Author: Jonathan Wakely <email@example.com>
Date: Wed May 27 21:58:56 2020 +0100
libstdc++: Fix std::reverse_iterator comparisons (PR 94354)
The std::reverse_iterator comparisons have always been implemented only
in terms of equality and less than. In C++98 that made no difference for
reasonable code, because when the underlying operators are the same type
they are required to support all comparisons anyway.
But since LWG 280 it's possible to compare reverse_iterator<X> and
reverse_iterator<Y>, and comparisons between X and Y might not support
the full set of equality and relational operators. This means that it
matters whether we implement operator!= as x.base() != y.base() or
!(x.base() == y.base()), and the current implementation is
This was already fixed in GCC 10.1 for C++20, this change also fixes it
for all other -std modes.
* include/bits/stl_iterator.h (reverse_iterator): Fix comparison
operators to use the correct operations on the underlying
* testsuite/24_iterators/reverse_iterator/rel_ops.cc: New test.
More information about the Gcc-bugs