libstdc++/6791: hash_map: bad end() iterator
paolo@gcc.gnu.org
paolo@gcc.gnu.org
Fri May 24 10:36:00 GMT 2002
Synopsis: hash_map: bad end() iterator
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Fri May 24 10:36:38 2002
Responsible-Changed-Why:
Triaged.
State-Changed-From-To: open->closed
State-Changed-By: paolo
State-Changed-When: Fri May 24 10:36:38 2002
State-Changed-Why:
User error. See Josuttis pp. 204-205 for a clear
explanation of why this is, in general, an incorrect use
of erase() (it works for map only "by chance"). In a
nutshell, fooH.erase(iter) invalidates iter as an iterator
of HT and the following ++iter results in undefined
behavior. The correct way is the following:
...
for (HT::iterator iter=fooH.begin(); iter!=fooH.end();) {
cerr << "erasing\n";
fooH.erase(iter++);
}
...
Thanks for your report, Paolo.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6791
More information about the Gcc-bugs
mailing list