This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See for the official list.


2345. Jumping across initializers in init-statements and conditions

Section: 8.5.2  [stmt.if]     Status: CD5     Submitter: John Spicer     Date: 2017-04-25

According to 8.5.2 [stmt.if] paragraph 1,

If the condition (8.5 []) yields true the first substatement is executed. If the else part of the selection statement is present and the condition yields false, the second substatement is executed. If the first substatement is reached via a label, the condition is not evaluated and the second substatement is not executed.

Although 8.8 [stmt.dcl] paragraph 3 forbids bypassing a declaration with initialization, a condition is not syntactically a declaration, and the permission to jump into a then clause and the statement that the condition “is not evaluated” could be read to indicate that a jump across a condition with initialization is permitted. Presumably the prohibition in 8.8 [stmt.dcl] would apply to an init-statement, since it can be a declaration syntactically, but one would expect the same restrictions to apply to both.

Notes from the April, 2018 teleconference:

This issue will be handled editorially (see editorial issue 1949) and will be left in "review" status until CWG verifies that the necessary changes have been made.