This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/41628] _GLIBCXX_DEBUG feature: check for unstable iterators
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Oct 2009 09:42:29 -0000
- Subject: [Bug libstdc++/41628] _GLIBCXX_DEBUG feature: check for unstable iterators
- References: <bug-41628-7596@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from redi at gcc dot gnu dot org 2009-10-08 09:42 -------
set::insert never invalidates iterators, so that's not a good example.
set::erase invalidates iterators pointing to erased elements, but debug mode
already catches that.
One problem I see with this request is that when debug mode detects a problem
it aborts the program. If I understand your request correctly, it would mean
that programs could abort when they haven't done anything wrong, e.g.
std::set<int> s;
std::set<int>::iterator i = s.insert(5);
s.erase(2);
return *i;
The erase call would have updated the mutation count so it no longer matches
the iterator's mutation count, but the program is correct so why should it
abort?
If I've misunderstood, could you give an example of problems you want to solve?
--
redi at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jwakely dot gcc at gmail dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41628