<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2474</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="2474"></A><H4>2474.
  
Cv-qualification and deletion
</H4>
<B>Section: </B>7.6.2.9&#160; [<A href="https://wg21.link/expr.delete">expr.delete</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD6
 &#160;&#160;&#160;

 <B>Submitter: </B>Unknown
 &#160;&#160;&#160;

 <B>Date: </B>2020-10-29<BR>


<P>[Accepted as a DR at the June, 2021 meeting.]</P>

<P>(From editorial issue
<A HREF="https://github.com/cplusplus/draft/issues/4305">4305</A>.)</P>

<P>According to 7.6.2.9 [<A href="https://wg21.link/expr.delete#3">expr.delete</A>] paragraph 3,</P>

<BLOCKQUOTE>

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.

</BLOCKQUOTE>

<P>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?</P>

<P><B>Notes from the December, 2020 teleconference:</B></P>

<P>&#8220;Similar types&#8221; raises issues with arrays of
unknown bounds, but a change to allow for differences in
cv-qualification is needed.</P>

<P><B>Notes from the May 25, 2021 teleconference:</B></P>

<P>It was observed that current implementations store
the total number of class objects in a multi-dimensional
array in a &#8220;cookie&#8221; 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 &#8220;similar&#8221; criterion was appropriate.</P>

<P><B>Proposed resolution, May, 2021:</B></P>

<P>Change 7.6.2.9 [<A href="https://wg21.link/expr.delete#3">expr.delete</A>] paragraph 3 as follows:</P>

<BLOCKQUOTE>

In a single-object delete expression, if the static type of
the object to be deleted is <DEL>different from</DEL>
<INS>not similar (7.3.6 [<A href="https://wg21.link/conv.qual">conv.qual</A>]) to</INS> 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
<DEL>differs from</DEL> <INS>is not similar to</INS> its
static type, the behavior is undefined.

</BLOCKQUOTE>

<BR><BR>
</BODY>
</HTML>
