This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
[Accepted as a DR at the June, 2021 meeting.]
(From editorial issue 4305.)
According to 7.6.2.9 [expr.delete] paragraph 3,
In a single-object delete expression, if the static type of the object to be deleted is different from its dynamic type and the selected deallocation function (see below) is not a destroying operator delete, the static type shall be a base class of the dynamic type of the object to be deleted and the static type shall have a virtual destructor or the behavior is undefined. In an array delete expression, if the dynamic type of the object to be deleted differs from its static type, the behavior is undefined.
Both the static type and the dynamic type include cv-qualification, and requiring agreement in qualification between the two for deletion is not intended. Perhaps the restriction should be to similar types instead of identical types?
Notes from the December, 2020 teleconference:
“Similar types” raises issues with arrays of unknown bounds, but a change to allow for differences in cv-qualification is needed.
Notes from the May 25, 2021 teleconference:
It was observed that current implementations store the total number of class objects in a multi-dimensional array in a “cookie” in the array allocation overhead, rather than the number of top-level array elements, and thus are able to invoke the destructors correctly even if the type being deleted is an array of unknown bound. Consequently, it was decided that use of the “similar” criterion was appropriate.
Proposed resolution, May, 2021:
Change 7.6.2.9 [expr.delete] paragraph 3 as follows:
In a single-object delete expression, if the static type of the object to be deleted isdifferent fromnot similar (7.3.6 [conv.qual]) to its dynamic type and the selected deallocation function (see below) is not a destroying operator delete, the static type shall be a base class of the dynamic type of the object to be deleted and the static type shall have a virtual destructor or the behavior is undefined. In an array delete expression, if the dynamic type of the object to be deleteddiffers fromis not similar to its static type, the behavior is undefined.