This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-10-26
[Moved to DR at the October, 2015 meeting.]
It would be helpful to have a single grammar term for expression and braced-init-list, which often occur together in the text. In particular, 8.6.5 [stmt.ranged] paragraph 1 allows both, but the description of __RangeT refers only to the expression case; such errors would be less likely if the common term were available.
Proposed resolution (May, 2015):
Add a new production to the grammar in 9.4 [dcl.init] paragraph 1:
Change the grammar in 7.6.1 [expr.post] paragraph 1 as follows:
Change the grammar in 8.6 [stmt.iter] paragraph 1 as follows:
Change 8.6.5 [stmt.ranged] paragraph 1 as follows:
For a range-based for statement of the form
for ( for-range-declaration : expression ) statement
let range-init be equivalent to the expression surrounded by parentheses90
( expression )
and for a range-based for statement of the form
for ( for-range-declaration : braced-init-list ) statement
let range-init be equivalent to the braced-init-list. In each case, aA range-based for statement is equivalent to{ auto && __range =range-initfor-range-initializer; for ( auto __begin = begin-expr, __end = end-expr; __begin != __end; ++__begin ) { for-range-declaration = *__begin; statement } }where
if the for-range-initializer is an expression, it is regarded as if it were surrounded by parentheses (so that a comma operator cannot be reinterpreted as delimiting two init-declarators);
__range, __begin, and __end are variables defined for exposition only
,; and
_RangeT is the type of the expression, andbegin-expr and end-expr are determined as follows:
if
_RangeTthe for-range-initializer is an expression of array type R, begin-expr and end-expr are __range and __range + __bound, respectively, where __bound is the array bound. If_RangeTR is an array of unknown size or an array of incomplete type, the program is ill-formed;if
_RangeTthe for-range-initializer isaan expression of class type C, the unqualified-ids begin and end are looked up in the scope ofclass _RangeTC as if by class member access lookup (_N4868_.6.5.6 [basic.lookup.classref]), and if either (or both) finds at least one declaration, begin-expr and end-expr are __range.begin() and __range.end(), respectively;otherwise, begin-expr and end-expr are begin(__range) and end(__range), respectively, where begin and end are looked up in the associated namespaces (6.5.4 [basic.lookup.argdep]). [Note: Ordinary unqualified lookup (6.5.3 [basic.lookup.unqual]) is not performed. —end note]
Change the grammar of 8.7 [stmt.jump] paragraph 1 as follows:
Change 8.7.4 [stmt.return] paragraph 2 as follows:
Theexpression or braced-init-listexpr-or-braced-init-list of a return statement is called its operand. A return statement...
Change 12.4.5 [over.sub] paragraph 1 as follows:
operator[] shall be a non-static member function with exactly one parameter. It implements the subscripting syntax
postfix-expression [
expressionexpr-or-braced-init-list ]
or
postfix-expression [ braced-init-list ]Thus, a subscripting expression...