Question w.r.t. `'class Foo' has virtual functions but non-virtual destructor` warning.
Jonathan Wakely
cow@compsoc.man.ac.uk
Sat Mar 5 14:29:00 GMT 2005
On Sat, Mar 05, 2005 at 09:00:38AM -0500, Michael N. Moran wrote:
> In embedded system work, and I'm sure in other circumstances,
> it is the case that "placement new" is the norm and destructors
> invoked explicitly (never on an abstract reference,) and the
> delete operator goes unused.
I should never have just said "add a virtual dtor" without qualification
:)
I assume in specialised domains where you have to know what you're
doing you will also know whether a virtual dtor is appropriate (and
can use -Wno-non-virtual-dtor to suppress the warning). If you're not
sure who might use the class and what they'll do, you have to be more
careful.
I was too quick to suggest adding the virtual dtor, clear documentation
that says "don't use delete with this type" might do the job equally
well - the important thing is to prevent the problem happening.
jon
--
Message terminated with signal 11, SIGFAULT
More information about the Gcc
mailing list