I noticed a false negative when working with multidimensional arrays. I was not able to find an exact ticket for this in trac, the closest I can find are tickets #3545 and #4555.
I do not get an error message for the following:
I am working with git [ 49099e78... ].
int main()
{
int a[2][2];
a[0][0] = 0;
//Two problems. stemming from
// missing shift : Should be a[0][ (3&2) >> 1]
// 1) we are out of bounds on this axis (but in bounds in the array)
// 2) value is uninitialised
return a[0][(3&2)];
}
Is there a ticket for this problem?
Last edit: AnotherUser 2015-03-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear Cppcheck developers,
I noticed a false negative when working with multidimensional arrays. I was not able to find an exact ticket for this in trac, the closest I can find are tickets #3545 and #4555.
I do not get an error message for the following:
I am working with git [ 49099e78... ].
int main()
{
int a[2][2];
a[0][0] = 0;
//Two problems. stemming from
// missing shift : Should be a[0][ (3&2) >> 1]
// 1) we are out of bounds on this axis (but in bounds in the array)
// 2) value is uninitialised
return a[0][(3&2)];
}
Is there a ticket for this problem?
Last edit: AnotherUser 2015-03-13
we intentionally don't warn for this. however I agree it's suspicious.
yes the checker doesn't track individual array elements currently. if one element is initialized the checker assumes that the array is initialized.
I'd say these tickets are related: #3540 #4441 #4527
I think fixing those is a good start and we can worry about multidimensional arrays if that is still a problem later.
Last edit: Daniel Marjamäki 2015-03-14