<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1955</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="1955"></A><H4>1955.
  
<TT>#elif</TT> with invalid controlling expression
</H4>
<B>Section: </B>15.2&#160; [<A href="https://wg21.link/cpp.cond">cpp.cond</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jonathan Wakely
 &#160;&#160;&#160;

 <B>Date: </B>2014-06-25
  &#160;&#160;&#160;
  <B>Liaison: </B>WG14<BR>


<P>[Adopted at the February, 2016 meeting.]</P>



<P>An <TT>#elif</TT> is treated differently from an <TT>#else</TT>
followed immediately by an <TT>#if</TT>: assuming the preceding
<TT>#if</TT>'s condition was <TT>true</TT>, the condition in the
second <TT>#if</TT> need not be a valid <I>expression</I>, while
the condition in the <TT>#elif</TT> directive, though not evaluated,
still must be syntactically correct.</P>

<P>
<A HREF="http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_412.htm">
C DR 412</A> changes that for C; C++ should make the corresponding
change.</P>

<P><B>Proposed resolution (November, 2014):</B></P>

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

<BLOCKQUOTE>

Each directive's condition is checked in order. If it
evaluates to false (zero), the group that it controls is
skipped: directives are processed only through the name that
determines the directive in order to keep track of the level
of nested conditionals; the rest of the directives'
preprocessing tokens are ignored, as are the other
preprocessing tokens in the group. Only the first group
whose control condition evaluates to true (nonzero) is
processed<INS>; any following groups are skipped and their
controlling directives are processed as if they were in a
group that is skipped</INS>. If none of the conditions...

</BLOCKQUOTE>

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