16.2.10 for Statements
- V is definitely assigned after a
for
statement iff both of the following are true:
- Either a condition expression is not present or V is definitely assigned after the condition expression when false.
- V is definitely assigned before every
break
statement that may exit the for
statement.
- V is definitely assigned before the initialization part of the
for
statement iff V is definitely assigned before the for
statement.
- V is definitely assigned before the condition part of the
for
statement iff V is definitely assigned after the initialization part of the for
statement.
- V is definitely assigned before the contained statement iff either of the following is true:
- A condition expression is present and V is definitely assigned after the condition expression when true.
- No condition expression is present and V is definitely assigned after the initialization part of the
for
statement.
- V is definitely assigned before the incrementation part of the
for
statement iff V is definitely assigned after the contained statement and V is definitely assigned before every continue
statement that may exit the body of the for
statement.
16.2.10.1 Initialization Part
- If the initialization part of the
for
statement is a local variable declaration statement, the rules of §16.2.3 apply.
- Otherwise, if the initialization part is empty, then V is definitely assigned after the initialization part iff V is definitely assigned before the initialization part.
- Otherwise, three rules apply:
- V is definitely assigned after the initialization part iff V is definitely assigned after the last expression statement in the initialization part.
- V is definitely assigned before the first expression statement in the initialization part iff V is definitely assigned before the initialization part.
- V is definitely assigned before an expression statement E other than the first in the initialization part iff V is definitely assigned after the expression statement immediately preceding E.
16.2.10.2 Incrementation Part
- If the incrementation part of the
for
statement is empty, then V is definitely assigned after the incrementation part iff V is definitely assigned before the incrementation part.
- Otherwise, three rules apply:
- V is definitely assigned after the incrementation part iff V is definitely assigned after the last expression statement in the incrementation part.
- V is definitely assigned before the first expression statement in the incrementation part iff V is definitely assigned before the incrementation part.
- V is definitely assigned before an expression statement E other than the first in the incrementation part iff V is definitely assigned after the expression statement immediately preceding E.