<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 618</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="618"></A><H4>618.
  
Casts in preprocessor conditional 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>Martin Sebor
 &#160;&#160;&#160;

 <B>Date: </B>12 February 2007
  &#160;&#160;&#160;
  <B>Liaison: </B>WG14<BR>


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



<P>15.2 [<A href="https://wg21.link/cpp.cond#1">cpp.cond</A>] paragraph 1 states,</P>

<BLOCKQUOTE>

The expression that controls conditional inclusion shall be an
integral constant expression except that: it shall not contain a
cast...

</BLOCKQUOTE>

<P>The prohibition of casts is vacuous and misleading: as
pointed out in the footnote in that paragraph, </P>

<BLOCKQUOTE>

Because the controlling constant expression is evaluated during
translation phase 4, all identifiers either are or are not macro names
&#8212; there simply are no keywords, enumeration constants, and so on.

</BLOCKQUOTE>

<P>As a result, there can be no casts, which require either
keywords or identifiers that resolve to types in order to be
recognized as casts.  The wording on casts should be removed and
replaced by a note recognizing this implication.</P>

<P><B>Notes from the April, 2007 meeting:</B></P>

<P>The CWG agreed with this suggested resolution; however, the
reference is in the &#8220;Preprocessing Directives&#8221; clause,
which WG21 intends to keep in as close synchronization as possible
with the corresponding wording in the C Standard.  Any change here
must therefore be done in consultation with WG14.  Clark Nelson will
fulfill this liaison function.</P>

<P>It was also noted that the imminent introduction of
<TT>constexpr</TT> also has the potential for a similar kind of
confusion, so the proposed resolution should address both casts and
<TT>constexpr</TT>.</P>

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

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

<BLOCKQUOTE>

The expression that controls conditional inclusion shall be an
integral constant expression except that: <DEL>it shall not contain a
cast;</DEL> identifiers (including those lexically identical to
keywords)...

</BLOCKQUOTE>

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