Title
Jumping across initializers in init-statements and conditions
Status
cd5
Section
8.5.2 [stmt.if]
Submitter
John Spicer

Created on 2017-04-25.00:00:00 last changed 24 months ago

Messages

Date: 2018-04-15.00:00:00

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.

Date: 2017-04-25.00:00:00

According to 8.5.2 [stmt.if] paragraph 1,

If the condition (8.5 [stmt.select]) 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.

History
Date User Action Args
2022-11-10 15:02:37adminsetstatus: review -> cd5
2018-04-11 00:00:00adminsetmessages: + msg6185
2018-04-11 00:00:00adminsetstatus: open -> review
2017-04-25 00:00:00admincreate