public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "chris at bubblescope dot net" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/23633] map::insert() invalidates reverse_iterators Date: Tue, 30 Aug 2005 15:49:00 -0000 [thread overview] Message-ID: <20050830153534.24471.qmail@sourceware.org> (raw) In-Reply-To: <20050830125045.23633.relf@os2.ru> ------- 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
next prev parent reply other threads:[~2005-08-30 15:35 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-08-30 13:01 [Bug c++/23633] New: " relf at os2 dot ru 2005-08-30 14:15 ` [Bug libstdc++/23633] " pinskia at gcc dot gnu dot org 2005-08-30 15:49 ` chris at bubblescope dot net [this message] 2005-08-30 20:21 ` chris at bubblescope dot net 2005-08-31 10:13 ` pcarlini at suse dot de
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=20050830153534.24471.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /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).