https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89700
Bug ID: 89700 Summary: Warn if move constructor is not generated and not deleted Product: gcc Version: 9.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: antoshkka at gmail dot com Target Milestone: --- It would be great to have a warning that helps to identify classes with sub-optimal move semantics. Foe example it would be nice to have such a warning for cases like following: struct member { member(); member(const member&); member(member&&); private: int* data_; }; // warninig: `my_class(const my_class&)` disables the // implicit move constructor generation. Use // `my_class(my_class&) = default;` to generate it or // `my_class(my_class&) = delete;` to disable this warning. struct my_class { my_class() = default; my_class(const my_class&); private: member member1; member member2; }; void foo(my_class c); void test() { my_class c; foo(static_cast<my_class&&>(c)); // copies } 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.