With head and this
int main() { int D[] = {1,2,3}; int j = (sizeof(D) / sizeof(E))-1; int a; int i; for(i=0;i< j ; i++) a = D[i]; }
and this command line
./cppcheck --bug-hunting ../FP2.c
I get :
../FP2.c:9:10: error: Array index out of bounds, cannot determine that i is less than 3 [bughuntingArrayIndexOutOfBounds] a = D[i]; ^ ../FP2.c:9:10: error: Array index out of bounds, cannot determine that i is not negative [bughuntingArrayIndexNegative] a = D[i]; ^
could someone check I'm not going made i.e cppcheck should know i is positive and the bounds of the loop.
thanks! I have created ticket https://trac.cppcheck.net/ticket/10757
Thanks, just for my interest does this mean that with out bug hunting enabled there is a possibility of false negatives in normal operation ?
No. Bug hunting uses a totally separated and very different value flow analysis. It was written from scratch to be "soundy".
Thanks for the extra info.
Log in to post a comment.
With head and this
and this command line
I get :
Last edit: dp11 2022-01-17
could someone check I'm not going made i.e cppcheck should know i is positive and the bounds of the loop.
thanks! I have created ticket https://trac.cppcheck.net/ticket/10757
Thanks, just for my interest does this mean that with out bug hunting enabled there is a possibility of false negatives in normal operation ?
No. Bug hunting uses a totally separated and very different value flow analysis. It was written from scratch to be "soundy".
Last edit: Daniel Marjamäki 2022-01-22
Thanks for the extra info.