The following results in a false positive containerOutOfBounds defect:
void f() { auto v = std::vector<std::vector<S*>>(3, std::vector<S*>()); v[2]; }
With cppcheck 2.16.0 (and also the current HEAD):
test.cxx:3:4: error: Out of bounds access in 'v[2]', if 'v' size is 2 and '2' is 2 [containerOutOfBounds] v[2]; ^
The problem disappears if one omits the default value, i.e. uses auto v = std::vector<std::vector<S*>>(3).
auto v = std::vector<std::vector<S*>>(3)
https://trac.cppcheck.net/ticket/13450
Log in to post a comment.
The following results in a false positive containerOutOfBounds defect:
With cppcheck 2.16.0 (and also the current HEAD):
The problem disappears if one omits the default value, i.e. uses
auto v = std::vector<std::vector<S*>>(3)
.https://trac.cppcheck.net/ticket/13450