public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/67342] New: Ill-formed move constructor ignored in favor of copy constructor @ 2015-08-24 19:07 barry.revzin at gmail dot com 2015-08-24 19:28 ` [Bug c++/67342] " redi at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: barry.revzin at gmail dot com @ 2015-08-24 19:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67342 Bug ID: 67342 Summary: Ill-formed move constructor ignored in favor of copy constructor Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- In the following code, A is neither movable nor copyable, and B has an A: #include <utility> struct A { A() { } A(A const&) = delete; A(A&& ) = delete; }; struct B { A a; B() = default; B(B const& ) : a() { } B(B&& ) = default; }; int main() { B b1; B b2(std::move(b1)); } I would expect the move constructor to be preferred and this code to fail to compile (with some diagnostic relating to the deleted A&& constructor), but instead gcc (and clang) prefers the copy constructor for b2 here and the code compiles. I suspect this is a compiler bug, as if I instead defaulted the copy constructor, gcc issues a diagnostic about "error: use of deleted function 'B::B(B&&)'" ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/67342] Ill-formed move constructor ignored in favor of copy constructor 2015-08-24 19:07 [Bug c++/67342] New: Ill-formed move constructor ignored in favor of copy constructor barry.revzin at gmail dot com @ 2015-08-24 19:28 ` redi at gcc dot gnu.org 2015-08-24 19:29 ` redi at gcc dot gnu.org 2015-08-24 19:43 ` barry.revzin at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: redi at gcc dot gnu.org @ 2015-08-24 19:28 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67342 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- The compiler is correct, see [class.copy]/11. B(B&&) is defaulted, so is defined as deleted, and "A defaulted move constructor that is defined as deleted is ignored by overload resolution" ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/67342] Ill-formed move constructor ignored in favor of copy constructor 2015-08-24 19:07 [Bug c++/67342] New: Ill-formed move constructor ignored in favor of copy constructor barry.revzin at gmail dot com 2015-08-24 19:28 ` [Bug c++/67342] " redi at gcc dot gnu.org @ 2015-08-24 19:29 ` redi at gcc dot gnu.org 2015-08-24 19:43 ` barry.revzin at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: redi at gcc dot gnu.org @ 2015-08-24 19:29 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67342 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1402 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/67342] Ill-formed move constructor ignored in favor of copy constructor 2015-08-24 19:07 [Bug c++/67342] New: Ill-formed move constructor ignored in favor of copy constructor barry.revzin at gmail dot com 2015-08-24 19:28 ` [Bug c++/67342] " redi at gcc dot gnu.org 2015-08-24 19:29 ` redi at gcc dot gnu.org @ 2015-08-24 19:43 ` barry.revzin at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: barry.revzin at gmail dot com @ 2015-08-24 19:43 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67342 --- Comment #3 from Barry Revzin <barry.revzin at gmail dot com> --- Thanks! I was pretty sure I was wrong but couldn't figure out why. Barry On Mon, Aug 24, 2015, 2:29 PM redi at gcc dot gnu.org < gcc-bugzilla@gcc.gnu.org> wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67342 > > --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- > http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1402 > > -- > You are receiving this mail because: > You reported the bug. > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-08-24 19:43 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-08-24 19:07 [Bug c++/67342] New: Ill-formed move constructor ignored in favor of copy constructor barry.revzin at gmail dot com 2015-08-24 19:28 ` [Bug c++/67342] " redi at gcc dot gnu.org 2015-08-24 19:29 ` redi at gcc dot gnu.org 2015-08-24 19:43 ` barry.revzin at gmail dot com
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).