Movatterモバイル変換


[0]ホーム

URL:


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

2025-12-20


2474. Cv-qualification and deletion

Section:7.6.2.9  [expr.delete]    Status:CD6    Submitter:Unknown    Date:2020-10-29

[Accepted as a DR at the June, 2021 meeting.]

(From editorial issue4305.)

According to 7.6.2.9 [expr.delete] paragraph 3,

In a single-object delete expression, if the static type ofthe object to be deleted is different from its dynamic typeand the selected deallocation function (see below) is not adestroying operator delete, the static type shall be a baseclass of the dynamic type of the object to be deleted andthe static type shall have a virtual destructor or thebehavior is undefined. In an array delete expression, if thedynamic type of the object to be deleted differs from itsstatic type, the behavior is undefined.

Both the static type and the dynamic type includecv-qualification, and requiring agreement in qualification betweenthe two for deletion is not intended. Perhaps the restrictionshould be to similar types instead of identical types?

Notes from the December, 2020 teleconference:

“Similar types” raises issues with arrays ofunknown bounds, but a change to allow for differences incv-qualification is needed.

Notes from the May 25, 2021 teleconference:

It was observed that current implementations storethe total number of class objects in a multi-dimensionalarray in a “cookie” in the array allocationoverhead, rather than the number of top-level arrayelements, and thus are able to invoke the destructorscorrectly even if the type being deleted is an array ofunknown bound. Consequently, it was decided that use ofthe “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 ofthe object to be deleted isdifferent fromnot similar (7.3.6 [conv.qual]) to itsdynamic type and the selected deallocation function (seebelow) is not a destroying operator delete, the static typeshall be a base class of the dynamic type of the object tobe deleted and the static type shall have a virtualdestructor or the behavior is undefined. In an array deleteexpression, if the dynamic type of the object to be deleteddiffers fromis not similar to itsstatic type, the behavior is undefined.



[8]ページ先頭

©2009-2026 Movatter.jp