<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1732</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="1732"></A><H4>1732.
  
Defining types in <I>condition</I>s and range-based <TT>for</TT> statements
</H4>
<B>Section: </B>8.5&#160; [<A href="https://wg21.link/stmt.select">stmt.select</A>]
 &#160;&#160;&#160;

 <B>Status: </B>C++14
 &#160;&#160;&#160;

 <B>Submitter: </B>Richard Smith
 &#160;&#160;&#160;

 <B>Date: </B>2013-08-08<BR>


<P>[Moved to DR at the February, 2014 meeting.]</P>



<P>The interaction of various issue resolutions has inadvertently resulted
in the loss of the prohibition of defining types in <I>condition</I>s
(8.5 [<A href="https://wg21.link/stmt.select#1">stmt.select</A>] paragraph 1) and in a range-based <TT>for</TT>
(8.6 [<A href="https://wg21.link/stmt.iter#1">stmt.iter</A>] paragraph 1).  <A HREF="686.html">Issue 686</A>
addressed a patchwork of restrictions by banning type definitions in
<I>type-specifier-seq</I>s.  <A HREF="948.html">Issue 948</A> then
changed the definition of <I>condition</I> to use a
<I>decl-specifier-seq</I> instead of a <I>type-specifier-seq</I> in order
to permit the <TT>constexpr</TT> specifier.  A similar change was made for
range-based <TT>for</TT> statements by <A HREF="1204.html">issue 1204</A>.</P>

<P>The restrictions against type definitions in these contexts should be
restored.</P>

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

<OL>
<LI><P>Change 8.5 [<A href="https://wg21.link/stmt.select#2">stmt.select</A>] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

The rules for conditions apply both
to <I>selection-statement</I>s and to the <TT>for</TT>
and <TT>while</TT> statements
(8.6 [<A href="https://wg21.link/stmt.iter">stmt.iter</A>]). The declarator shall not specify
a function or an array. <INS>The <I>decl-specifier-seq</I>
shall not define a class or enumeration.</INS> If the
<TT>auto</TT> <I>type-specifier</I> appears in
the <I>decl-specifier-seq</I>, the type of the identifier
being declared is deduced from the initializer as described
in 9.2.9.7 [<A href="https://wg21.link/dcl.spec.auto">dcl.spec.auto</A>].

</BLOCKQUOTE>

<LI><P>Change 8.6.5 [<A href="https://wg21.link/stmt.ranged#2">stmt.ranged</A>] paragraph 2 as follows:</P></LI>

<BLOCKQUOTE>

In the <I>decl-specifier-seq</I> of
a <I>for-range-declaration</I>, each <I>decl-specifier</I>
shall be either a <I>type-specifier</I> or <TT>constexpr</TT>.
<INS>The <I>decl-specifier-seq</I> shall not define a class or
enumeration.</INS>

</BLOCKQUOTE>

</OL>

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