|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug440.cpp
The school bookstore is computing its annual budget. The array StuCourse indicates whether Student i is taking Course j and CostBook indicates the cost of the book for Course j. But something is going awry. Can you spot it? bug440.cpp lint Output
--- Module: bug440.cpp (C++)
_
for( j = 0; j < NCrs; i++ )
bug440.cpp 10 Warning 440: for clause irregularity: variable 'j' tested in
2nd expression does not match 'i' modified in 3rd
bug440.cpp 10 Warning 443: for clause irregularity: variable 'j' initialized
in 1st expression does not match 'i' modified in 3rd
bug440.cpp 10 Warning 445: Reuse of for loop variable 'i' at 'line 9' could
cause chaos
bug440.cpp 9 Info 830: Location cited in prior message
_
return cost;
bug440.cpp 13 Info 850: for loop index variable 'i' whose type category is
'integral' is modified in body of the for loop that began at 'line 9'
bug440.cpp 9 Info 830: Location cited in prior message
Reference Manual Explanation
440 for clause irregularity: variable 'Symbol' tested in 2nd expression
does not match 'Symbol' modified in 3rd -- A for clause has a suspicious
structure. The loop variable, as determined by an examination of the
3rd for clause expression, does not match the variable that is tested
in the 2nd for clause expression. For example:
for( i = 0; i < 10; j++ )
...
would draw this complaint since the 'i' of the 2nd expression does not
match the 'j' of the third expression.
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #578 - September 2008