This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/59171] pretty printers: reverse iterator off by one
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 14 Dec 2016 17:24:59 +0000
- Subject: [Bug libstdc++/59171] pretty printers: reverse iterator off by one
- Auto-submitted: auto-generated
- References: <bug-59171-4@http.gcc.gnu.org/bugzilla/>
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.