<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 601</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="601"></A><H4>601.
  
Type of literals in preprocessing expressions
</H4>
<B>Section: </B>15.2&#160; [<A href="https://wg21.link/cpp.cond">cpp.cond</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>23 October 2006
  &#160;&#160;&#160;
  <B>Liaison: </B>WG14<BR>


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

<P>The description of preprocessing expressions in
15.2 [<A href="https://wg21.link/cpp.cond#4">cpp.cond</A>] paragraph 4 says,</P>

<BLOCKQUOTE>

The resulting tokens comprise the controlling constant expression
which is evaluated according to the rules of 5.19 using arithmetic
that has at least the ranges specified in 17.3 [<A href="https://wg21.link/support.limits">support.limits</A>],
except that all signed and unsigned integer types act as if they have
the same representation as, respectively, <TT>intmax_t</TT> or
<TT>uintmax_t</TT> (18.3.2).

</BLOCKQUOTE>

<P>However, this does not address the type implicitly assigned to
integral literals.  For example, in an implementation where <TT>int</TT>
is 32 bits and <TT>long long</TT> is 64 bits, is a literal like
<TT>0xffffffff</TT> signed or unsigned?  WG14 adopted
<A HREF="http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_265.htm">
DR 265</A> to deal with this issue in the essentially-identical
wording in C99; we should probably follow suit for C++.</P>

<P><B>Proposed Resolution (July, 2009):</B></P>

<P>Change 15.2 [<A href="https://wg21.link/cpp.cond#4">cpp.cond</A>] paragraph 4 as follows:</P>

<BLOCKQUOTE>

...and then each preprocessing token is converted into a token. The
resulting tokens comprise the controlling constant expression which is
evaluated according to the rules of 7.7 [<A href="https://wg21.link/expr.const">expr.const</A>] using
arithmetic that has at least the ranges specified in 17.3 [<A href="https://wg21.link/support.limits">support.limits</A>]<DEL>, except that</DEL><INS>. For the purposes of this token
conversion and evaluation</INS> all signed and unsigned integer types
act as if they have the same representation as,
respectively, <TT>intmax_t</TT> or <TT>uintmax_t</TT> (_N3035_.18.4.2 [<A href="https://wg21.link/stdinth">stdinth</A>])<INS>[<I>Footnote:</I> Thus on an implementation where
<TT>std::numeric_limits&lt;int&gt;::max()</TT> is 0x7FFF and
<TT>std::numeric_limits&lt;unsigned int&gt;::max()</TT> is 0xFFFF,
the integer literal <TT>0x8000</TT> is signed and positive within a
<TT>#if</TT> expression even though it is unsigned in translation
phase 7 (5.2 [<A href="https://wg21.link/lex.phases">lex.phases</A>]). &#8212;<I>end footnote</I>]</INS>.
This includes interpreting character literals...

</BLOCKQUOTE>

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