|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home Page bug568.cpp
Our programmer wanted to print the lengths of some lines from standard in but the program is behaving erratically. What's going on?
bug568.cpp lint Output
--- Module: bug568.cpp
_
while( --n >= 0 )
bug568.cpp(15) : Warning 685: Relational operator '>=' always evaluates to
'true'
bug568.cpp(15) : Warning 568: non-negative quantity is never less than zero
_
printf( "%d\n", a[n] );
bug568.cpp(17) : Info 817: Conceivably negative subscript (-1) in operator '['
[Reference: file bug568.cpp: lines 9, 15, 17]
Reference Manual Explanation
568 nonnegative quantity is never less than zero. --
Comparisons of the form:
u >= 0 0 <= u
u < 0 0 > u
are suspicious if u is an unsigned quantity or a quantity
judged to be never less then 0. See also message 775.
|
Previous Bug - Bug #1729 - March 2002