public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: paolo@gcc.gnu.org To: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, paolo@gcc.gnu.org, vograno@arbitrade.com Subject: Re: libstdc++/6791: hash_map: bad end() iterator Date: Fri, 24 May 2002 10:46:00 -0000 [thread overview] Message-ID: <20020524173639.20026.qmail@sources.redhat.com> (raw) 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
next reply other threads:[~2002-05-24 17:36 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-05-24 10:46 paolo [this message] -- strict thread matches above, loose matches on Subject: below -- 2002-05-24 11:36 Vadim Ogranovich 2002-05-23 20:26 vograno
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020524173639.20026.qmail@sources.redhat.com \ --to=paolo@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ --cc=gcc-gnats@gcc.gnu.org \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@gcc.gnu.org \ --cc=vograno@arbitrade.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).