![]() |
![]() |
2470 | ![]() |
||||
![]() | |||||||
| Control flow | |||||||
The address of the loop control variable in this loop construct is being used. QA·C attempts to identify a loop control variable when analysing for loops and whileloops. 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 of a loop is associated with a single local variable and it is important that modification of its value is clearly understood. In this case, by taking the address of the loop control variable, it is possible that its value may be modified through a pointer alias. This could be confusing and dangerous. For example:
/*PRQA S 2017,2211,2469,3198,3203,3227,3408,3447 ++*/
extern void mix(int *p);
extern void f1(int n)
{
int i;
for (i = 0; i > n; ++i)
{
mix(&i); /* Message 2470 */
}
}
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |