Hello and again thanks for the project.
I was wondering about a warning I can reproduce with this short code sample:
int main() { std::vector<int> a = {0, 1, 2, 3}; std::vector<std::vector<int>> as = {a, a, a}; for (auto &ais : as) { ais.erase(ais.begin()); // Iterator 'ais.begin()' from different container 'ais' are used together. } }
Is this a false positive? I'm not sure to get why this code would be dangerous?
Thanks!
Which version do you use? It seems this is fixed in head,
I tested it first with 2.6.2.
But indeed, I checked now with HEAD and it looks like it works fine now. Thanks and sorry for the noise.
I am getting a similar false-positive in version 2.7 on Windows x64:
if (someInt >= 0) { myStdVector.erase(myStdVector.begin() + someInt); }
Cppcheck 2.7 reports:
Iterator 'myStdVector.begin()+someInt' from different container 'myStdVector' are used together.
There is no warning with current head for
void f(std::vector<int> v, int i) { if (i >= 0) { v.erase(v.begin() + i); } }
Log in to post a comment.
Hello and again thanks for the project.
I was wondering about a warning I can reproduce with this short code sample:
Is this a false positive? I'm not sure to get why this code would be dangerous?
Thanks!
Which version do you use? It seems this is fixed in head,
I tested it first with 2.6.2.
But indeed, I checked now with HEAD and it looks like it works fine now. Thanks and sorry for the noise.
I am getting a similar false-positive in version 2.7 on Windows x64:
Cppcheck 2.7 reports:
Iterator 'myStdVector.begin()+someInt' from different container 'myStdVector' are used together.
There is no warning with current head for