|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug416.cpp
This is the start of a larger program to monitor beer consumption at a large gathering, but the program already has a serious problem. Can you spot it? bug416.cpp lint Output
--- Module: bug416.cpp
During Specific Walk:
File bug416.cpp line 8: upper_bound(10001)
bug416.cpp 17 Warning 416: Likely creation of out-of-bounds pointer (2 beyond
end of data) by operator 'ptr+int' [Reference: file bug416.cpp: lines 8, 17]
--- Wrap-up for Module: bug416.cpp
Info 750: local macro 'LIMIT' (line 2, file bug416.cpp) not referenced
Reference Manual Explanation
416 creation of out-of-bounds pointer ('Integer' beyond end of data) by
operator 'String' -- An out-of-bounds pointer was created. See
message 415 for a description of the parameters Integer and String.
For example:
int a[10];
...
f( a + 11 );
Here, an illicit pointer value is created and is flagged as such by
PC-lint/FlexeLint. Note that the pointer a+10 is not considered by
PC-lint/FlexeLint to be the creation of an out-of-bounds pointer. This
is because ANSI C explicitly allows pointing just beyond an array. Access
through a+10, however, as in *(a+10) or the more familiar a[10], would
be considered erroneous but in that case message 415 would be issued.
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #722 - September 2005