<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2698</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="2698"></A><H4>2698.
  
Using extended integer types with <TT>z</TT> suffix
</H4>
<B>Section: </B>5.13.2&#160; [<A href="https://wg21.link/lex.icon">lex.icon</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>2023-02-17
  &#160;&#160;&#160;
  <B>Liaison: </B>WG14, EWG<BR>


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

<P>Subclause 5.13.2 [<A href="https://wg21.link/lex.icon#4">lex.icon</A>] paragraph 4 specifies:</P>

<BLOCKQUOTE>

If an <I>integer-literal</I> cannot be represented by any type in its
list and an extended integer type (6.9.2 [<A href="https://wg21.link/basic.fundamental">basic.fundamental</A>]) can
represent its value, it may have that extended integer type. If all of
the types in the list for the <I>integer-literal</I> are signed, the
extended integer type shall be signed. If all of the types in the list
for the <I>integer-literal</I> are unsigned, the extended integer type
shall be unsigned. If the list contains both signed and unsigned
types, the extended integer type may be signed or unsigned. A program
is ill-formed if one of its translation units contains
an <I>integer-literal</I> that cannot be represented by any of the
allowed types.

</BLOCKQUOTE>

<P>This implies that an <I>integer-literal</I> with a <TT>z</TT>
suffix can be of extended integer type, if the literal is larger than
what is representable in <TT>std::size_t</TT>.</P>

<P>According to the author of the paper
<A HREF="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0330r8.html">P0330R8</A>
(Literal Suffix for (signed) size_t) introducing the feature, this is
unintentional; <TT>z</TT> should only yield <TT>std::size_t</TT> and
its corresponding signed integer type.</P>

<P>See also the corresponding WG14 paper
<A HREF="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2998.htm">N2998
Literal Suffixes for size_t</A>.</P>

<P><B>Proposed resolution (reviewed by CWG 2023-03-03, approved by CWG 2023-05-12):</B></P>

<P>Change in 5.13.2 [<A href="https://wg21.link/lex.icon#4">lex.icon</A>] paragraph 4 as follows:</P>

<BLOCKQUOTE>

<DEL>If</DEL> <INS>Except for <I>integer-literal</I>s containing
a <I>size-suffix</I>, if the value of</INS> an <I>integer-literal</I>
cannot be represented by any type in its list and an extended integer
type (6.9.2 [<A href="https://wg21.link/basic.fundamental">basic.fundamental</A>]) can represent its value, it may have
that extended integer type. If all of the types in the list for
the <I>integer-literal</I> are signed, the extended integer type
<DEL>shall be </DEL> <INS>is</INS> signed. If all of the types in the
list for the <I>integer-literal</I> are unsigned, the extended integer
type <DEL>shall be</DEL> <INS>is</INS> unsigned. If the list contains
both signed and unsigned types, the extended integer type may be
signed or unsigned. <DEL>A program is ill-formed if one of its
translation units contains</DEL> <INS>If</INS> an
<I>integer-literal</I> <DEL>that</DEL> cannot be represented by any
of the allowed types<INS>, the program is ill-formed</INS>.
<INS>[ Note: An <I>integer-literal</I> with a <TT>z</TT> or <TT>Z</TT>
suffix is ill-formed if it cannot be represented by
<TT>std::size_t</TT>.  -- end note ]</INS>

</BLOCKQUOTE>

<P><B>Additional notes (February, 2023)</B></P>

<P>Alerted the chair of SG22 (C/C++ Liaison).</P>

<P>Forwarded to EWG at the request of the EWG chair via
<A HREF="https://github.com/cplusplus/papers/issues/1467">cplusplus/papers#1467</A>.</P>

<P><B>EWG 2023-05-11</B></P>

<P>The "z" suffixes mean <TT>std::size_t</TT> (or its corresponding
signed type) only.  The proposed resolution is accepted by EWG.</P>

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