<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 599</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="599"></A><H4>599.
  
Deleting a null function pointer
</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>CD2
 &#160;&#160;&#160;

 <B>Submitter: </B>Martin Sebor
 &#160;&#160;&#160;

 <B>Date: </B>3 October 2006<BR>


<P>[Voted into WP at July, 2009 meeting.]</P>

<P>The requirements for the operand of the <TT>delete</TT> operators are
given in 7.6.2.9 [<A href="https://wg21.link/expr.delete#2">expr.delete</A>] paragraph 2:</P>

<BLOCKQUOTE>

In either alternative, the value of the operand of <TT>delete</TT> may
be a null pointer value. If it is not a null pointer value, in the
first alternative (<I>delete object</I>), the value of the operand
of <TT>delete</TT> shall be a pointer to a non-array object or a
pointer to a subobject (6.8.2 [<A href="https://wg21.link/intro.object">intro.object</A>]) representing a
base class of such an object (11.7 [<A href="https://wg21.link/class.derived">class.derived</A>]). If not,
the behavior is undefined. In the second alternative (<I>delete
array</I>), the value of the operand of <TT>delete</TT> shall be the
pointer value which resulted from a previous
array <I>new-expression</I>. If not, the behavior is undefined.

</BLOCKQUOTE>

<P>There are no restrictions on the type of a null pointer, only on
a pointer that is not null.  That seems wrong.</P>

<P><B>Proposed resolution (June, 2008):</B></P>

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

<BLOCKQUOTE>

...The operand shall have a pointer <INS>to object</INS> type, or a
class type having a single non-explicit conversion function
(11.4.8.3 [<A href="https://wg21.link/class.conv.fct">class.conv.fct</A>]) to a pointer
<INS>to object</INS> type...

</BLOCKQUOTE>

<P><B>Proposed resolution (September, 2008):</B></P>

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

<BLOCKQUOTE>

...The operand shall have a pointer <INS>to object</INS> type, or a
class type having a single non-explicit conversion function
(12.3.2) to a pointer <INS>to object</INS> type. <INS>[<I>Footnote:</I>
This implies that an object cannot be deleted using a pointer of
type <TT>void*</TT> because <TT>void</TT> is not an object type.
&#8212;<I>end footnote</I>]</INS> ...

</BLOCKQUOTE>

<LI><P>Delete the footnote at the end of 7.6.2.9 [<A href="https://wg21.link/expr.delete#3">expr.delete</A>] paragraph 3:
</P></LI>

<BLOCKQUOTE>

...if the dynamic type of the object to be deleted differs from
its static type, the behavior is undefined. <DEL>[<I>Footnote:</I>
This implies that an object cannot be deleted using a pointer of
type <TT>void*</TT> because there are no objects of type
<TT>void</TT>. &#8212;<I>end footnote</I>]</DEL>

</BLOCKQUOTE>
</OL>

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