|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug662.cpp
This is a whittled down version of the source code for an electronic vote counting machine. But the program contains a fundamental flaw. Can you spot it? bug662.cpp lint Output
--- Module: bug662.cpp (C++)
_
vote[v]++;
bug662.cpp 14 Warning 662: Possible creation of out-of-bounds pointer (2
beyond end of data) by operator '[' [Reference: file bug662.cpp: lines 13,14]
_
vote[v]++;
bug662.cpp 14 Warning 661: Possible access of out-of-bounds pointer (2
beyond end of data) by operator '[' [Reference: file bug662.cpp: lines 13,14]
Reference Manual Explanation
662 possible creation of out-of-bounds pointer ('Integer' beyond end
of data) by operator 'String' -- An out-of-bounds pointer may
have been created. See message 415 for a description of the
parameters Integer and String. For example:
int a[10];
if( n <= 20 ) f( a + n );
Here, it appears as though an illicit pointer is being created,
but PC-lint/FlexeLint cannot be certain. See also messages 416
and 797. See §9.2 Value Tracking
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #666 - October 2006