[Bug c++/89700] Warn if move constructor is not generated and not deleted

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Mar 13 22:26:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89700

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
You're mistaken.

struct X
{
  std::string str = "not empty";
  X() = default;
  X(const X&) = default;
};

This type does not have a move constructor. Copying an rvalue will perform a
copy (not a move):

  X x1;
  X x2 = std::move(x1);  // calls copy constructor

But it does not have a deleted move constructor. It has no move constructor.
That's different. If it had a deleted move constructor then the initialization
of x2 above would fail to compile.


More information about the Gcc-bugs mailing list