[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 15:10:00 GMT 2019


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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Antony Polukhin from comment #0)
> The rules for the warning could be following:
> Issue a warning if at least one of the class members has a move constructor,
> class has a copy constructor and the move constructor is not implicitly
> deleted.

I like the idea in general, but I'm not sure this rule is right, or how to
workaround the warning.

A class might intentionally want to copy so its members are never left in a
moved-from state, so the warning would not be helpful for that class. But I
can't think of a convenient way for the class author to indicate that the
behaviour is as intended. They can't delete the move constructor (that makes
the class non-movable), and they can't default it (that would leave members in
moved-from states).


More information about the Gcc-bugs mailing list