<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1204</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="1204"></A><H4>1204.
  
Specifiers in a <I>for-range-declaration</I>
</H4>
<B>Section: </B>8.6&#160; [<A href="https://wg21.link/stmt.iter">stmt.iter</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>2010-10-01<BR>


<P>[Voted into the WP at the March, 2011 meeting as part of paper N3262.]</P>



<P>It seems unfortunate that the beginning of a C-style <TT>for</TT>
loop can look like</P>

<UL>
<TT>for (</TT> <I>attribute-specifier<SUB>opt</SUB> decl-specifier-seq<SUB>opt</SUB> declarator</I>
</UL>

<P>whereas the beginning of a range-based <TT>for</TT> loop looks like</P>

<UL>
<TT>for (</TT> <I>attribute-specifier<SUB>opt</SUB> type-specifier-seq<SUB>opt</SUB> declarator</I>
</UL>

<P>So that we don't know what constraints we are trying to apply to
the specifiers until we see, or don't see, a <TT>:</TT>.  The
inconsistency between <I>decl-specifier-seq</I> and
<I>type-specifier-seq</I> seems gratuitous and inconvenient.</P>

<P><B>Proposed resolution (November, 2010) [SUPERSEDED]:</B></P>

<OL>
<LI><P>Change the grammar 8.6 [<A href="https://wg21.link/stmt.iter#1">stmt.iter</A>] paragraph 1 as
follows:</P></LI>

<UL>
<I>for-range-declaration:</I>
<UL><I>attribute-specifier<SUB>opt</SUB> <DEL>type-specifier-seq</DEL> <INS>decl-specifier-seq</INS> declarator</I></UL>

</UL>

<LI><P>Add the following as a new paragraph at the end of 8.6.5 [<A href="https://wg21.link/stmt.ranged">stmt.ranged</A>]:</P></LI>

<BLOCKQUOTE>

<INS>The 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>

</BLOCKQUOTE>

</OL>

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