This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/59171] pretty printers: reverse iterator off by one


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]