From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30412 invoked by alias); 14 May 2003 23:46:01 -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 30345 invoked by uid 71); 14 May 2003 23:46:01 -0000 Resent-Date: 14 May 2003 23:46:01 -0000 Resent-Message-ID: <20030514234601.30344.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, gandy@abacho.de Received: (qmail 28379 invoked by uid 48); 14 May 2003 23:45:16 -0000 Message-Id: <20030514234516.28378.qmail@sources.redhat.com> Date: Wed, 14 May 2003 23:46:00 -0000 From: gandy@abacho.de Reply-To: gandy@abacho.de To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/10794: std::map's erase method invalidates reverse_iterators X-SW-Source: 2003-05/txt/msg01727.txt.bz2 List-Id: >Number: 10794 >Category: libstdc++ >Synopsis: std::map's erase method invalidates reverse_iterators >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed May 14 23:46:01 UTC 2003 >Closed-Date: >Last-Modified: >Originator: gandy@abacho.de >Release: libstdc++5-3.3 >Organization: >Environment: debian linux: ii libstdc++5 3.3-0pre9 ii libstdc++5-3.3-dev 3.3-0pre9 ii libstdc++5-3.3-doc 3.3-0pre9 ii libstdc++5-dev 3.2.3-2 ii g++ 3.2.3-1 ii g++-3.2 3.2.3-2 ii g++-3.3 3.3-0pre9 >Description: Programm output (g++-3.2 and g++-3.3): -90 270 -90 -90 Expected output: -90 -90 -90 -90 Note that the reverse_iterator jt is NOT pointing to the element which is erased. Citation from SGI STL Docu: Erasing an element from a map also does not invalidate any iterators, except, of course, for iterators that actually point to the element that is being erased. I would think that applies to reverse_iterators, too. >How-To-Repeat: #include #include using namespace std; int main() { map byloc; map::reverse_iterator jt; byloc.insert(pair(90, 1)); byloc.insert(pair(-90, 1)); byloc.insert(pair(270, 1)); byloc.insert(pair(-270, 1)); jt = byloc.rbegin(); jt++; jt++; cout << jt->first << endl; byloc.erase(90); cout << jt->first << endl; byloc.clear(); byloc.insert(pair(90, 1)); byloc.insert(pair(-90, 1)); byloc.insert(pair(270, 1)); jt = byloc.rbegin(); jt++; jt++; cout << jt->first << endl; byloc.erase(90); cout << jt->first << endl; return 0; } >Fix: >Release-Note: >Audit-Trail: >Unformatted: