I know that deleteing a null pointer is a no-op:
In either alternative, if the value of the operand of delete is the null pointer the operation has no effect.
(C++ Standard5.3.5 [expr.delete] p2)
And also that deleting a void* pointer is undefined behaviour because the destructor can’t be called as there are no objects of type void:
In the first alternative (
delete object), the value of the operand of delete shall be a pointer to a non-array object or a pointer to a sub-object representing a base class of such an object. If not, the behavior is undefined.
(C++ Standard5.3.5 [expr.delete] p2)
Now, normally I take it that things that are listed first overrule things that are listed later on, but what about null void* pointer as the following?
void* p = 0;
delete p; // UB or well-defined?
I wonder how you can reach up a situation where you are deleting a pointer only if it is null. But staying in language lawyering mode…
In C++ 03
5.3.5/1
void* is a pointer type so a null void pointer meets the static requirement.
5.3.5/2
And this gives the wanted behavior.
5.3.5/3
This is not relevant, a null pointer doesn’t reference an object on which to check the additional constraint.
In C++ 0X
5.3.5/1
void* isn’t a pointer to object type, so should be rejected.