Title
Cv-qualification and deletion
Status
cd6
Section
7.6.2.9 [expr.delete]
Submitter
Unknown

Created on 2020-10-29.00:00:00 last changed 28 months ago

Messages

Date: 2021-11-15.00:00:00

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 is different from not 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 deleted differs from is not similar to its static type, the behavior is undefined.
Date: 2021-11-15.00:00:00

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.

Date: 2020-12-15.00:00:00

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.

Date: 2021-06-15.00:00:00

[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?

History
Date User Action Args
2022-08-19 07:54:33adminsetstatus: drwp -> cd6
2021-11-15 00:00:00adminsetmessages: + msg6587
2021-11-15 00:00:00adminsetmessages: + msg6586
2021-11-15 00:00:00adminsetstatus: drafting -> drwp
2021-02-17 00:00:00adminsetmessages: + msg6489
2020-10-29 00:00:00admincreate