
On Nov 5, 2009, at 5:32 PM, Emil Dotchevski wrote:
On Thu, Nov 5, 2009 at 1:50 PM, Kim Barrett <kab.conundrums@verizon.net
wrote:
On Nov 5, 2009, at 2:04 PM, Emil Dotchevski wrote:
- non-virtual-dtor on GCC contradicts a valid design choice.
At least in recent versions of gcc, this warning is not generated when there is a non-public dtor.
This doesn't help much. [...] but it will complain in the derived class, which typically doesn't even define a destructor explicitly.
Yeah, the problem here is that there's no (easy?) way to indicate that the derived class is intended to be a leaf class. On the other hand, once one has paid the cost of making a class polymorphic anyway, is there really much (if any?) benefit to making its destructor non- virtual? Note that there's a related warning turned on by -Weffc++, namely: "Make destructors virtual in base classes." This one warns if a class with a non-virtual dtor is used as a base class. It triggers regardless of the accessibility of that dtor. That pretty clearly warns about perfectly safe and sensible code.