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

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).