Created on 2012-07-16.00:00:00 last changed 48 months ago
[Voted into the WP at the July, 2017 meeting.]
Proposed resolution (May, 2017):
Add the following as a new pareagraph following 6.4.2 [basic.scope.pdecl] paragraph 9:
The point of declaration for a function-local predefined variable (9.5 [dcl.fct.def]) is immediately before the function-body of a function definition.
The point of declaration for the variable or the structured bindings declared in the for-range-declaration of a range-based for statement (8.6.5 [stmt.ranged]) is immediately after the for-range-initializer.
The point of declaration for a template parameter...
Notes from the April, 2013 meeting:
The approach favored by CWG for resolving this issue is to change the point of declaration of the variable in the for-range-declaration to be after the ).
Notes from the October, 2012 meeting:
EWG is discussing issue 900 and the outcome of that discussion should be taken into consideration in addressing this issue.
According to the general rule for declarations in 6.4.2 [basic.scope.pdecl] paragraph 1,
The point of declaration for a name is immediately after its complete declarator (9.3 [dcl.decl]) and before its initializer (if any), except as noted below.
However, the rewritten expansion of the range-based for statement in 8.6.5 [stmt.ranged] paragraph 1 contradicts this general rule, so that the index variable is not visible in the range-init:
for (int i : {i}) ; // error: i not in scope
(See also issue 1498 for another question regarding the rewritten form of the range-based for.)
History | |||
---|---|---|---|
Date | User | Action | Args |
2020-12-15 00:00:00 | admin | set | status: drwp -> cd5 |
2018-02-27 00:00:00 | admin | set | messages: + msg6136 |
2018-02-27 00:00:00 | admin | set | messages: + msg6135 |
2018-02-27 00:00:00 | admin | set | status: drafting -> drwp |
2013-05-03 00:00:00 | admin | set | messages: + msg4333 |
2013-05-03 00:00:00 | admin | set | status: open -> drafting |
2012-11-03 00:00:00 | admin | set | messages: + msg4113 |
2012-07-16 00:00:00 | admin | create |