![]() |
![]() |
2464 | ![]() |
||||
![]() | |||||||
| Control flow | |||||||
The control variable is modified more than once in this for-loop statement. QA·C attempts to identify a control variable when analysing a for-loop. Sometimes this is not possible because the concept of a loop control variable is not an intrinsic feature of the C language and loop control may depend on more than one variable. However in most situations, control is associated with a single local variable and it is important that modification of its value is clearly understood. In this case the control variable is being modified in both the 2nd expression and the 3rd expression. This is likely to be confusing and should be avoided if possible. For example:
/*PRQA S 2017,3120,3408,3416,3440 ++*/
extern void foo(void)
{
int j;
for (j = 0; j++ < 10; j++) /* Message 2464 */
{
}
}
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |