PC-lint/FlexeLint Output | Reference Manual Explanation | Home Page
1 const int KMAX = 30;
2 double q[KMAX];
3
4 void f( double limit )
5 {
6 double s = 1;
7 int k = 0;
8 q[0] = 0;
9 while( q[k] <= limit && k < KMAX )
10 {
11 k++;
12 s = s * (k+1);
13 q[k] = q[k-1] + s;
14 }
15 }
There is a "time-bomb" lurking in this whittled-down extraction of a larger program. Can you spot it?
--- Module: bug661.cpp
_
q[k] = q[k-1] + s;
bug661.cpp 13 Warning 661: Possible access of out-of-bounds pointer
(1 beyond end of data) by operator '['
661 possible access of out-of-bounds pointer ('Integer' beyond end of
data) by operator 'String' -- An out-of-bounds pointer may have
been accessed. See message 415 for a description of the
parameters Integer and String. For example:
int a[10];
if( n <= 10 ) a[n] = 0;
Here the programmer presumably should have written n<10. This
message is similar to messages 415 and 796 but differs from them
by the degree of probability.
See Value Tracking
Previous Bug - Bug #1547 - January 1998
Next Bug - Bug #1411 - March 1998