From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5453 invoked by alias); 30 Aug 2005 12:51:06 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 5362 invoked by uid 48); 30 Aug 2005 12:50:54 -0000 Date: Tue, 30 Aug 2005 13:01:00 -0000 From: "relf at os2 dot ru" To: gcc-bugs@gcc.gnu.org Message-ID: <20050830125045.23633.relf@os2.ru> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/23633] New: map::insert() invalidates reverse_iterators X-Bugzilla-Reason: CC X-SW-Source: 2005-08/txt/msg03442.txt.bz2 List-Id: gcc (GCC) 4.0.2 20050821 (prerelease) (Debian 4.0.1-6) In the following program inserting a new element into a map (i.e., M[2]=2) invalidates an existing map::reverse_iterator im2. Before this insertion the reverse_iterator im2 points to the pair (1,1), and after the insertion it becomes erroneously pointing to the newly inserted pair (2,2). There is no such problem with map::iterator m1. Sample output: before insertion: im1->first = 1 im2->first = 1 after insertion: im1->first = 1 im2->first = 2 #include #include using namespace std; int main() { map M; M[1] = 1; map::iterator im1=M.begin(); map::reverse_iterator im2=M.rbegin(); cout << "before insertion:" << endl; cout << "im1->first = " << im1->first << endl; cout << "im2->first = " << im2->first << endl; M[2] = 2; cout << "after insertion:" << endl; cout << "im1->first = " << im1->first << endl; cout << "im2->first = " << im2->first << endl; return 0; } -- Summary: map::insert() invalidates reverse_iterators Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: relf at os2 dot ru CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23633