public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "tudorb at fb dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/57049] std::swap does self move assignment, which is illegal Date: Tue, 23 Apr 2013 15:54:00 -0000 [thread overview] Message-ID: <bug-57049-4-yQTcH9LyI4@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-57049-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57049 --- Comment #1 from Tudor Bosman <tudorb at fb dot com> 2013-04-23 15:54:18 UTC --- Actually, I'll take this back. I don't believe this is a bug. 17.6.4.9 constraints arguments passed to STL functions. So if there is a library function that takes a rvalue argument (such as string::operator=(string&& other)), then the library is free to assume that the argument doesn't alias (so &other != this). So the assertion in basic_fbstring is correct. The default implementation of swap() does self-move assignment. That would be illegal if the types were MoveAssignable STL types (because then they'd call T::operator=(T&&) which would be illegal according to 17.6.4.9) BUT ALL STL TYPES HAVE SPECIALIZED IMPLEMENTATIONS OF SWAP which don't do self move assignment. So the default swap() will do self-move-assignment on user types, but there's no language in the standard that bans self-move-assignment there.
next prev parent reply other threads:[~2013-04-23 15:54 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-04-23 15:46 [Bug libstdc++/57049] New: " tudorb at fb dot com 2013-04-23 15:54 ` tudorb at fb dot com [this message] 2013-04-25 9:55 ` [Bug libstdc++/57049] " daniel.kruegler at googlemail dot com 2013-06-11 9:00 ` paolo.carlini at oracle dot com
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-57049-4-yQTcH9LyI4@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).