Deleting a POD via a pointer to base
8.3.5 [expr.delete]
Herb Sutter

Created on 2011-03-10.00:00:00 last changed 63 months ago


Date: 2015-04-13.00:00:00

Additional note, April, 2015:

EWG has decided not to make a change in this area. See EWG issue 99.

Date: 2011-08-15.00:00:00

Rationale (August, 2011):

The specification is as intended; changes to the restriction would need to be considered in a larger context by EWG.

Date: 2012-02-27.00:00:00

It is currently undefined behavior to delete a derived-class object via a pointer to a base class unless the base class has a virtual destructor. It has been suggesed that this could be allowed for a standard-layout class. If so, presumably the caveats about a deallocation function or non-trivial destructor found in 8.3.5 [expr.delete] paragraph 5 that currently apply to incomplete types would need to be extended to apply to the derived class in such cases.

Another objection that was raised is that such a change would make it more difficult to extend C++ in the future to have global deallocation functions that can take the size of the object being deleted as an argument, as is currently possible for member deallocation functions.

Date User Action Args
2015-04-13 00:00:00adminsetmessages: + msg5429
2015-04-13 00:00:00adminsetstatus: extension -> nad
2012-02-27 00:00:00adminsetmessages: + msg3863
2011-03-10 00:00:00admincreate