Hi,
void test_function() { int myArray[10];
for (int i = 0; i < 20; i++) { myArray[i] = i * 5; } ...
}
Please can I ask why Cppcheck doesn't detect the "obvious" out of bounds error in the code?
test.cpp:7:12: error: Array 'myArray[10]' accessed at index 19, which is out of bounds. [arrayIndexOutOfBounds] myArray[i] = i * 5; ^ test.cpp:5:19: note: Assuming that condition 'i<20' is not redundant for (int i = 0; i < 20; i++) ^ test.cpp:7:12: note: Array index out of bounds myArray[i] = i * 5; ^
Works for me with head.
Log in to post a comment.
Hi,
void test_function()
{
int myArray[10];
}
Please can I ask why Cppcheck doesn't detect the "obvious" out of bounds error in the code?
Works for me with head.