This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


1259. Deleting a POD via a pointer to base

Section: 7.6.2.9  [expr.delete]     Status: NAD     Submitter: Herb Sutter     Date: 2011-03-10

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 7.6.2.9 [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.

Rationale (August, 2011):

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

Additional note, April, 2015:

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