Path: utzoo!attcan!uunet!ncrlnk!ncr-sd!hp-sdd!hplabs!analog2!ward!smith From: smith@ward.UUCP (Tom Smith) Newsgroups: comp.lang.c++ Subject: Re: Virtual Destructors? Message-ID: <332@ward.UUCP> Date: 27 Dec 88 20:13:01 GMT References: <8590@alice.UUCP> Organization: Analog Design Tools Inc., Sunnyvale, CA. Lines: 20 From article <8590@alice.UUCP>, by ark@alice.UUCP (Andrew Koenig): > If you want a destructor to be virtual, make it virtual: > [ example of virtual destructor ] > > Be aware that there is a fairly widespread bug that causes virtual > destructors not to work quite right unless all derived classes have > explicit destructors, even if the destructors are empty. There is also a bug in our translator (Glockenspiel, derived from AT&T) that could well exist in most, if not all. It goes thusly: Ordinarily, the delete operator is defined to "do the correct thing" when the operand is a pointer of any type set to zero. However, if the operand is a pointer to an instance of a class with a virtual destructor, and the pointer is set to zero, the resulting code tries to dereference the pointer to call the virtual function without checking for a zero value first. Of course, this crashes your application promptly. Thomas Smith hplabs!analog!smith