From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24511 invoked by alias); 30 Aug 2005 15:35:39 -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 24472 invoked by uid 48); 30 Aug 2005 15:35:34 -0000 Date: Tue, 30 Aug 2005 15:49:00 -0000 Message-ID: <20050830153534.24471.qmail@sourceware.org> From: "chris at bubblescope dot net" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050830125045.23633.relf@os2.ru> References: <20050830125045.23633.relf@os2.ru> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug libstdc++/23633] map::insert() invalidates reverse_iterators X-Bugzilla-Reason: CC X-SW-Source: 2005-08/txt/msg03471.txt.bz2 List-Id: ------- Additional Comments From chris at bubblescope dot net 2005-08-30 15:35 ------- While this behaviour is suprising, it is also not a bug. The problem comes from the fact that &*(reverse_iterator(i)) = &*(i-1), so when you dereference a reverse_iterator the value you actually get is from the iterator before the one is stored inside the reverse_iterator (I hope that makes sense). That might seem strange, but there are good reasons for it, and it's unavoidable. in std::map, this causes problems, as the an iterator can be inserted between i and i-1 (as in this case here), making the thing a reverse_iterator points at can change. Personally, I've always considered reverse_iterator a bit of a nasty hack. In this case I'm sure we are correct with respect to the standard, and there really isn't a good way to fix either map or reverse_iterator so this code acts as you expect I'm afraid. -- What |Removed |Added ---------------------------------------------------------------------------- CC| |chris at bubblescope dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23633