This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/59170] pretty printers: end iterator invalid pointer
- From: "jan.kratochvil at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 13 Dec 2016 14:57:48 +0000
- Subject: [Bug libstdc++/59170] pretty printers: end iterator invalid pointer
- Auto-submitted: auto-generated
- References: <bug-59170-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59170
--- Comment #8 from Jan Kratochvil <jan.kratochvil at redhat dot com> ---
(In reply to Jonathan Wakely from comment #7)
> That doesn't help:
>
> std::vector<int>::iterator it;
> {
> std::vector<int> v{1};
> it = v.begin();
> }
>
> The iterator is safely initialized, safely updated to a valid value, but is
> not dereferenceable after the last statement.
At the "}" line container gets destructed which should invalidate "it"
according to my last paragraph of Comment 6 and then "print it" would print a
message "invalidated iterator". Sure fully-managed iterators are a larger
feature request than this PR.
> "print it" should not automatically dereference.
This is GCC maintainers opinion; not mine.
> But most code isn't compiled with debug mode enabled.
IMO all code for debugging with pretty printers is compiled with debug mode
enabled. The other case are Linux system -O2 -g packages which are not really
debuggable up to the level of C++ containers at all. One is glad to get a
partially readable backtrace for a crash of a system package.