[Bug libstdc++/59171] pretty printers: reverse iterator off by one
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Dec 14 17:25:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59171
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Actually I'm not sure what can be done to fix this.
In the general case we can't print the correct value, because we may not be
able to increment the 'current' member to point to the object that would result
from dereferencing the reverse_iterator. The code for ++current might not be
present in the executable.
Even if we could do that, we'd get inconsistent behaviour depending on the type
of current. If it's a container from the C++03 standard library then we'd
automatically dereference it (because the iterators from those containers have
pretty printers that auto-dereference), if it's a pointer, or a user-defined
iterator, or and iterator from a container from the C++11 standard library then
we don't have a printer and so won't auto-dereference it. Which is yet another
reason not to automatically dereference iterators.
More information about the Gcc-bugs
mailing list