<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 277</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="277"></A><H4>277.
  
Zero-initialization of pointers
</H4>
<B>Section: </B>9.5&#160; [<A href="https://wg21.link/dcl.init">dcl.init</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Andrew Sawyer
 &#160;&#160;&#160;

 <B>Date: </B>5 Apr 2001<BR>


<P>[Moved to DR at 10/01 meeting.]</P>



<P>The intent of 9.5 [<A href="https://wg21.link/dcl.init#5">dcl.init</A>] paragraph 5 is that
pointers that are zero-initialized will contain a null pointer
value.  Unfortunately, the wording used,</P>

<BLOCKQUOTE>

...set to the value of 0 (zero) converted to <TT>T</TT>

</BLOCKQUOTE>

<P>does not match the requirements for creating a null pointer
value given in 7.3.12 [<A href="https://wg21.link/conv.ptr#1">conv.ptr</A>] paragraph 1:</P>

<BLOCKQUOTE>

A <I>null pointer constant</I> is an integral constant expression
(7.7 [<A href="https://wg21.link/expr.const">expr.const</A>]) rvalue of integer type that evaluates to
zero. A null pointer constant can be converted to a pointer type; the
result is the <I>null pointer value</I> of that type...

</BLOCKQUOTE>

<P>The problem is that the "value of 0" in the description of
zero-initialization is not specified to be an integral constant
expression.  Nonconstant expressions can also have the value 0,
and converting a nonconst 0 to pointer type need not result in
a null pointer value.</P>

<P><B>Proposed resolution (04/01):</B></P>

<P>In 9.5 [<A href="https://wg21.link/dcl.init#5">dcl.init</A>] paragraph 5, change</P>

<BLOCKQUOTE>

...set to the value 0 (zero) converted to <TT>T</TT>;

</BLOCKQUOTE>

<P>to</P>

<BLOCKQUOTE>

...set to the value 0 (zero), taken as an integral constant
expression, converted to <TT>T</TT>; [<I>footnote:</I> as
specified in 7.3.12 [<A href="https://wg21.link/conv.ptr">conv.ptr</A>], converting an integral
constant expression whose value is 0 to a pointer type results
in a null pointer value.]

</BLOCKQUOTE>

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