Created on 2022-08-24.00:00:00 last changed 16 months ago
Proposed resolution (approved by CWG 2022-08-26):
Append to 8.1 [stmt.pre] paragraph 3 as follows:
... A statement S1 is enclosed by a statement S2 if S2 encloses S1.
The rules for conditions apply both...
Change in 8.2 [stmt.label] paragraph 2 as follows:
Case labels and default labels shall occur only in switch statementsA labeled-statement whose label is a case or default label shall be enclosed by (8.1 [stmt.pre]) a switch statement (8.5.3 [stmt.switch])..
Change in 8.7.2 [stmt.break] paragraph 1 as follows:
TheA break statement shalloccur only inbe enclosed by (8.1 [stmt.pre]) an iteration-statement (8.6 [stmt.iter]) or a switch statementand(8.5.3 [stmt.switch]). The break statement causes termination of the smallest such enclosingiteration-statement or switchstatement; control passes to the statement following the terminated statement, if any.
Change in 8.7.3 [stmt.cont] paragraph 1 as follows:
TheA continue statement shalloccur only inbe enclosed by (8.1 [stmt.pre]) an iteration-statement (8.6 [stmt.iter])and. The continue statement causes control to pass to the loop-continuation portion of the smallest such enclosingiteration-statementstatement, that is, to the end of the loop. ...
[Accepted as a DR at the November, 2022 meeting.]
Consider:
for (int i = 0; i< 10; ++i){
auto f = [](){
break; // #1
};
}
Subclause 8.7.2 [stmt.break] paragraph 1 specifies:
The break statement shall occur only in an iteration-statement or a switch statement and causes termination of the smallest enclosing iteration-statement or switch statement; control passes to the statement following the terminated statement, if any.
Does the break at #1 "occur" in the for loop?
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-07-16 13:00:43 | admin | set | status: open -> c++23 |
2023-07-16 13:00:43 | admin | set | status: drwp -> open |
2023-02-18 18:43:04 | admin | set | status: dr -> drwp |
2022-11-25 05:14:04 | admin | set | status: ready -> dr |
2022-08-26 21:45:07 | admin | set | messages: + msg6910 |
2022-08-26 21:45:07 | admin | set | status: open -> ready |
2022-08-24 00:00:00 | admin | create |