public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "nevin at eviloverlord dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/61023] set/map move assignment doesn't move (or copy) the comparator Date: Thu, 01 May 2014 21:25:00 -0000 [thread overview] Message-ID: <bug-61023-4-8dmyky68Pr@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-61023-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61023 --- Comment #4 from Nevin Liber <nevin at eviloverlord dot com> --- Good point about the Standard. However, the current behavior for move assignment breaks the invariant of the container, since the comparator is what enforces the insertion ordering and element equivalence. Take for example: struct Compare { Compare(bool b) : b_(b) {} bool operator()(int l, int r) const { return b_ ? r < l : l < r; } bool b_; }; int main() { typedef std::set<int, Compare> S; S s(Compare(false)); s.insert(2); s.insert(3); S abracadabra(Compare(true)); // The heisenbug 3... abracadabra = std::move(s); assert(abracadabra.find(2) == std::find(abracadabra.begin(), abracadabra.end(), 2)); // works assert(abracadabra.find(3) == std::find(abracadabra.begin(), abracadabra.end(), 3)); // fails } This behavior seems untenable to me. The implementation needs to do something more reasonable. Even something as drastic as deleting the ordered associative container move assignment when stateful comparators are involved is better than the status quo.
next prev parent reply other threads:[~2014-05-01 21:25 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-04-30 22:24 [Bug libstdc++/61023] New: " nevin at eviloverlord dot com 2014-04-30 22:27 ` [Bug libstdc++/61023] " nevin at eviloverlord dot com 2014-04-30 22:35 ` nevin at eviloverlord dot com 2014-05-01 21:25 ` nevin at eviloverlord dot com [this message] 2014-05-04 15:56 ` redi at gcc dot gnu.org 2014-05-06 23:50 ` ppluzhnikov at google dot com 2014-05-07 13:15 ` [Bug libstdc++/61023] [4.9/4.10 Regression] " redi at gcc dot gnu.org 2014-05-07 14:12 ` redi at gcc dot gnu.org 2014-05-07 14:13 ` redi at gcc dot gnu.org 2014-05-07 14:16 ` redi at gcc dot gnu.org
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=bug-61023-4-8dmyky68Pr@http.gcc.gnu.org/bugzilla/ \ --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).