For Loop: must update expression use only invariants?
Posted: Wed Nov 29, 2017 3:47 pm
MISRA C:2012 Rule 14.2 puts the following restriction on the "third clause" (called "expression" in C++:2008):
Shall not use objects that are modified in the for loop body.
For example, the following violates this rule:
I can't find a corresponding rule in C++:2008. Am I overlooking something?
- Stephen H. Westin
Shall not use objects that are modified in the for loop body.
For example, the following violates this rule:
Code: Select all
for (int i=0; i<500; i = i + j)
{
j = random();
}
- Stephen H. Westin