Fixed #2481 (false positive with 'break;': After insert, the iterator '*' may be invalid)
This commit is contained in:
parent
b1b8ea6457
commit
70eadb37bd
|
@ -642,7 +642,7 @@ void CheckStl::pushback()
|
|||
}
|
||||
}
|
||||
|
||||
else if (tok2->str() == "return")
|
||||
else if (tok2->str() == "return" || tok2->str() == "break")
|
||||
{
|
||||
invalidIterator.clear();
|
||||
}
|
||||
|
|
|
@ -222,6 +222,22 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Ticket #2481
|
||||
check("void foo(std::vector<int> &r)\n"
|
||||
"{\n"
|
||||
" std::vector<int>::iterator aI = r.begin();\n"
|
||||
" while(aI != r.end())\n"
|
||||
" {\n"
|
||||
" if (*aI == 0)\n"
|
||||
" {\n"
|
||||
" r.insert(aI, 42);\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
" ++aI;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Execution path checking..
|
||||
check("void foo(std::vector<int> &r, int c)\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue