From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24040 invoked by alias); 24 May 2002 18:36:04 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 24017 invoked by uid 71); 24 May 2002 18:36:02 -0000 Date: Fri, 24 May 2002 11:36:00 -0000 Message-ID: <20020524183602.24015.qmail@sources.redhat.com> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Vadim Ogranovich Subject: RE: libstdc++/6791: hash_map: bad end() iterator Reply-To: Vadim Ogranovich X-SW-Source: 2002-05/txt/msg00788.txt.bz2 List-Id: The following reply was made to PR libstdc++/6791; it has been noted by GNATS. From: Vadim Ogranovich To: "'paolo@gcc.gnu.org'" , "'gcc-bugs@gcc.gnu.org'", "'gcc-prs@gcc.gnu.org'" , "'nobody@gcc.gnu.org'" , "'paolo@gcc.gnu.org'", "'gcc-gnats@gcc.gnu.org'" Cc: Subject: RE: libstdc++/6791: hash_map: bad end() iterator Date: Fri, 24 May 2002 13:30:29 -0500 Sorry for the false report. Thank you for the explanations, Vadim -----Original Message----- From: paolo@gcc.gnu.org [mailto:paolo@gcc.gnu.org] Sent: Friday, May 24, 2002 10:37 AM 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 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&p r=6791 -------------------------------------------------- DISCLAIMER This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Knight Trading Group may, at its discretion, monitor and review the content of all e-mail communications.