Hi, I found a false negative regarding the rule arrayIndexOutOfBounds.
arrayIndexOutOfBounds
Cppcheck misses an out-of-bounds write when the array is accessed through a pointer alias.
int a[2]; void f() { int *p = a; p[2] = 0; }
Cppcheck does not report arrayIndexOutOfBounds. Replacing p[2] = 0 with a[2] = 0 produces the warning.
p[2] = 0
a[2] = 0
Cppcheck should report the out-of-bounds write through the alias.
The issue was reproduced with:
cppcheck --output-format=xmlv2 --enable=all array_alias.cpp
Version: 2.21.0
Log in to post a comment.
Hi, I found a false negative regarding the rule
arrayIndexOutOfBounds.Cppcheck misses an out-of-bounds write when the array is accessed through a pointer alias.
Actual result
Cppcheck does not report
arrayIndexOutOfBounds. Replacingp[2] = 0witha[2] = 0produces the warning.Expected result
Cppcheck should report the out-of-bounds write through the alias.
Verification
The issue was reproduced with:
Version: 2.21.0