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++/59170] pretty printers: end iterator invalid pointer


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.

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