virtual destructor unexpected pass

Todd Vierling tv@pobox.com
Wed Sep 2 05:36:00 GMT 1998


On 2 Sep 1998, Alexandre Oliva wrote:

: > If it's defined in another unit for the superclass, doesn't that mean it
: > shouldn't have the "= 0" clause (pure virtual)?
: 
: No, even a member function that is declared pure virtual can be
: given a definition, that will be used whenever a qualified name is
: used to refer to it.  Since the destructor of a subclass explicitly
: invokes the destructor of the superclass, a pure virtual destructor
: must be defined if any subclass of its containing class is
: destructed.

Then I reassert that the compiler should say something about this - if not
an error, then a warning.  If it's generating an implicit reference to
something declared pure virtual (where there is no _intent_ of making a real
function for the declaration), there should be at least a compiler warning
to the effect of:

warning: destructor for class `A' is pure virtual, but will be referenced by
subclasses

-- 
-- Todd Vierling (Personal tv@pobox.com; Bus. todd_vierling@xn.xerox.com)




More information about the Gcc-bugs mailing list