[cxx-abi-dev] complete object 'structors for abstract classes (was deleting destructors)
scott douglass
sdouglass at arm.com
Tue Oct 1 09:06:08 UTC 2002
At 30-09-02 08:41 AM -0700, Mark Mitchell wrote:
>--On Monday, September 30, 2002 10:21:46 AM +0100 scott douglass <sdouglass at arm.com> wrote:
>>At 30-09-02 01:33 AM -0700, Mark Mitchell wrote:
>>>--On Monday, September 30, 2002 09:00:23 AM +0100 scott douglass
>>><sdouglass at arm.com> wrote:
>>>
>>>>Hello,
>>>>
>>>>I've noticed that it's probably reasonable to not produce C1/D1/D0
>>>>'structors for abstract classes -- the language rules prevent ever
>>>>needing to construct or destruct a complete object of abstract type.
>>>
>>>You certinaly need D0:
>>>
>>>struct S { virtual void f () = 0; ~S (); };
>>>
>>>void g (S* sp) {
>>> delete sp;
>>>}
>>
>>I don't follow that. We know that sp must point to some class derived
>>from S (because S is abstract).
>
>Note that ~S is not virtual. [..]
You're right: I was misreading it as a virtual destructor. I can see why a compiler would make a direct reference to the D0 destructor. It's too bad the language allows calling delete on (a pointer to) an abstract type with a non-virtual destructor since it's going to be undefined behavior.
More information about the cxx-abi-dev
mailing list