Hi, I found a false negative regarding the rule arrayIndexOutOfBounds.
arrayIndexOutOfBounds
Cppcheck misses an out-of-bounds write when array indexing is written as pointer arithmetic.
int a[2]; void f() { *(a + 2) = 0; }
Cppcheck does not report arrayIndexOutOfBounds. Replacing *(a + 2) = 0 with a[2] = 0 produces the warning.
*(a + 2) = 0
a[2] = 0
Cppcheck should report the out-of-bounds write in both forms.
The issue was reproduced with:
cppcheck --output-format=xmlv2 --enable=all array_pointer.cpp
Version: 2.21.0
See https://trac.cppcheck.net/ticket/10201
Log in to post a comment.
Hi, I found a false negative regarding the rule
arrayIndexOutOfBounds.Cppcheck misses an out-of-bounds write when array indexing is written as pointer arithmetic.
Actual result
Cppcheck does not report
arrayIndexOutOfBounds. Replacing*(a + 2) = 0witha[2] = 0produces the warning.Expected result
Cppcheck should report the out-of-bounds write in both forms.
Verification
The issue was reproduced with:
Version: 2.21.0
See https://trac.cppcheck.net/ticket/10201