MISRA Discussion Forums

Full Version: Rule 14.2 What is meant by assign"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In the 1st clause what is meant by “assign a value to the loop counter”. May this “value” be an expression with side-effects?
Code:
int index;
for ( set_val(&index) ;  index < 10 ; index++) // Is this compliant if set_val assigns to index
Note: the 2nd and 3rd clauses explicitly refer to expressions and whether side-effects are permitted.
The first clause may assign a value to the loop counter via a function call which includes persistent side-effects.

The above example is compliant with this rule.