Question w.r.t. `'class Foo' has virtual functions but non-virtualdestructor` warning.
Mark Mitchell
mark@codesourcery.com
Sat Mar 5 01:06:00 GMT 2005
Chris Lattner wrote:
> I've run into this warning with C++ code as well, and it is quite
> annoying. There are lots of possible reasons to want to do this sort of
> thing, and adding a virtual dtor increases the size of the vtable for
> the class.
Yeah, there goes one whole pointer per class in your program image. :-)
Seriously, you'd have to have a lot of classes and not very many
objects before that got to be *too* big a deal. But, we do have
customers who count every byte, so I'm not totally discounting this
objection.
> It seems that the warning could be improved to be emitted when the
> *delete* is seen of a class without a virtual dtor (but that does have
> virtual methods). If you never actually do the questionable behavior,
> you'd never get the warning. It seems like a bug to emit it for the
> class definition.
Age-old debate: better to warn early about possibly broken interfaces,
or late about definitely broken usage? I think that warning early,
together with what DJ is calling fine-grained warning control is the
best solution.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
More information about the Gcc
mailing list