[cxx-abi-dev] When to emit deleting destructor
scott douglass
sdouglass at arm.com
Thu Oct 17 08:54:01 UTC 2002
Nelson, Clark wrote:
>>>>This is a good question; it is unspecified at present.
>>>>
>>>>G++'s D0 destructors do not handle a NULL this pointer.
>>>>
>>>>What do HP and Intel do?
>>>
>>Yes; we never heard from HP and Intel. HP, Intel?
>
>
> The Intel compiler checks for null in the expansion of the
> delete-expression, so it never passes a null pointer to a destructor. This
> seems to be required by the standard ("if the value of the operand of delete
> is the null pointer the operation has no effect", 5.3.5p2).
For a delete with a non-virtual destructor, having the check for null in D0 and not checking at the delete site still conforms to the standard. What's required is that the D1 destructor (including any user destructor code) is not called.
Aside: arguably you can still call the operator delete with the null since it too is required to have no effect but I would prefer to avoid calling operator delete if I'd already done the null check.
More information about the cxx-abi-dev
mailing list