Understanding -Weffc++

GCC’s -Weffc++ has several issues, I never use it. The code that checks for “problems” is pretty simplistic and so the warnings end up being far too blunt and unhelpful.

That particular warning is based on Item 11 of the first edition of Effective C++ and Scott changed it (for the better) in later editions. The G++ code doesn’t check for actual dynamic allocation, just the presence of pointer members.

See what I wrote about this warning in GCC’s bugzilla when comparing the guidelines in the first edition with the third edition:

Item 11: Define a copy constructor and an assignment operator for classes with
dynamically allocated memory.

Replaced by Item 14: “Think carefully about copying behavior in
resource-managing classes” – the advice is less specific, but more useful. I’m
not sure how to turn it into a warning though!

Leave a Comment