This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: virtual destructor unexpected pass
- To: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Subject: Re: virtual destructor unexpected pass
- From: Todd Vierling <tv at pobox dot com>
- Date: Tue, 1 Sep 1998 23:38:18 -0400 (EDT)
- cc: egcs-bugs at cygnus dot com
On 2 Sep 1998, Alexandre Oliva wrote:
: > It causes a link error that ~A() is undefined; I believe that the
: > destructor in A below is an error and there should be a compiler
: > error instead.
:
: Nope, it is valid to declare an pure virtual destructor, but it *must*
: be defined anyway if you instantiate any subclass of the class. A
: compile-time error would be wrong, because the destructor could be
: defined in another translation unit.
If it's defined in another unit for the superclass, doesn't that mean it
shouldn't have the "= 0" clause (pure virtual)? The problem I describe in
my case is that, in the case of the pure virtual destructor, that the
compiler still puts in references to this destructor - which does not, nor
will ever, exist! Hence the link error.
If this is standards-conformant to have a pure virtual destructor, I then
believe that the correct thing here is for the compiler to treat such a
destructor as being a null clause, i.e. {}. Otherwise, you can't use pure
virtual destructors, because they won't link.
--
-- Todd Vierling (Personal tv@pobox.com; Bus. todd_vierling@xn.xerox.com)