Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 14.2 What is meant by assign"
#1
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.
Posted by and on behalf of the MISRA C Working Group
Reply
#2
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.
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)