![]() |
![]() |
2469 | ![]() |
||||
![]() | |||||||
| Control flow | |||||||
The variable identified as the control variable in this 'for' loop has been modified inside the body of the loop. QAC identifies a control variable by examining the 3 'for-loop' expressions. Usually it is a variable in the 2nd expression and is the operand of a relational operator. In a conventional for loop, the loop control variable is only modified in the 3rd expression of the for statement. Modification in other places within the loop is likely to cause confusion. For example:
/*PRQA S 2017 ++*/
/*PRQA S 2017,3120,3199,3408 ++*/
extern void foo(void)
{
int j;
for (j = 0; j < 10; j++ )
{
++j; /* Message 2469 */
}
}
MISRA-C:2004 Rules applicable to message 2469:
| Rule 13.6 (Required) | Numeric variables being used within a for loop for iteration counting shall not be modified in the body of the loop. |
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |