virtual destructor unexpected pass

Todd Vierling tv@pobox.com
Wed Sep 2 11:35:00 GMT 1998


On Wed, 2 Sep 1998, Martin von Loewis wrote:

: struct X{
:   virtual ~X()=0;
: };

: is standard C++, and should be accepted. It is also meaningful; it
: says that class X is abstract, and no instances of it should be
: created. So I'm not sure I want a warning.

I believe a warning is warranted.  If you use the above instead of

struct X{
  virtual ~X();
};

(which is the same in meaning, excepting the abstractness), this deviation
from the normal handling of pure virtual functions (who are _never_
implicitly called) should be warned about.  That way you won't get a
head-scratching about "uh, but I declared it pure virtual, why is it calling
a nonexistent function?" just like I did.

IMHO, after the standards quote and the above behavior, I'd consider a pure
virtual destructor to be bad style.

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




More information about the Gcc-bugs mailing list