[Bug libstdc++/94354] std::reverse_iterator comparison operators defined incorrectly
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed May 27 20:59:24 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94354
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:
https://gcc.gnu.org/g:979e89a9a94f66241fa8355e2b2e8f4a680c83e1
commit r11-672-g979e89a9a94f66241fa8355e2b2e8f4a680c83e1
Author: Jonathan Wakely <jwakely@redhat.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
non-conforming.
This was already fixed in GCC 10.1 for C++20, this change also fixes it
for all other -std modes.
PR libstdc++/94354
* include/bits/stl_iterator.h (reverse_iterator): Fix comparison
operators to use the correct operations on the underlying
iterators.
* testsuite/24_iterators/reverse_iterator/rel_ops.cc: New test.
More information about the Gcc-bugs
mailing list