It would be nice for the C++ compiler to warn users when they implement copy assignment operator that does not copy all parts of an object.
Build the following (contrived) program at maximum warning level: class Copy { public: Copy() : m_value(0), m_flag(false) {} Copy& operator=(const Copy& source) { m_value = source.m_value; return *this; } private: int m_value; bool m_flag; }; int main() { Copy instance; Copy another; another = instance; return 0; } Results: No warning will results Expected: The C++ compiler could warn the user that certain members (i.e. m_flag) are not copied in the implementation of the copy assignment operator. -- Summary: GCC should warn about poorly implemented copy assignment operators Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: enhancement Priority: P5 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tron dot thomas at verizon dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24488