Specifiers in a for-range-declaration
8.6 [stmt.iter]
Jason Merrill

Created on 2010-10-01.00:00:00 last changed 91 months ago


Date: 2011-03-15.00:00:00

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

Date: 2010-11-15.00:00:00

Proposed resolution (November, 2010) [SUPERSEDED]:

  1. Change the grammar 8.6 [stmt.iter] paragraph 1 as follows:

    • for-range-declaration:
        attribute-specifieropt type-specifier-seq decl-specifier-seq declarator
  2. Add the following as a new paragraph at the end of 8.6.5 [stmt.ranged]:

  3. The the decl-specifier-seq of a for-range-declaration, each decl-specifier shall be either a type-specifier or constexpr.
Date: 2010-10-01.00:00:00

It seems unfortunate that the beginning of a C-style for loop can look like

    for ( attribute-specifieropt decl-specifier-seqopt declarator

whereas the beginning of a range-based for loop looks like

    for ( attribute-specifieropt type-specifier-seqopt declarator

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

Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3322
2011-04-10 00:00:00adminsetstatus: review -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3082
2010-11-29 00:00:00adminsetstatus: open -> review
2010-10-01 00:00:00admincreate