This commit is contained in:
parent
1798b73808
commit
17b538210d
|
@ -1370,7 +1370,7 @@ void CheckStl::eraseCheckLoopVar(const Scope &scope, const Variable *var)
|
||||||
// Vector erases are handled by invalidContainer check
|
// Vector erases are handled by invalidContainer check
|
||||||
if (isVector(tok->tokAt(-3)))
|
if (isVector(tok->tokAt(-3)))
|
||||||
continue;
|
continue;
|
||||||
if (Token::simpleMatch(tok->astParent(), "="))
|
if (Token::Match(tok->astParent(), "=|return"))
|
||||||
continue;
|
continue;
|
||||||
// Iterator is invalid..
|
// Iterator is invalid..
|
||||||
int indentlevel = 0U;
|
int indentlevel = 0U;
|
||||||
|
|
|
@ -4285,6 +4285,15 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:9]: (error) Out of bounds access in expression 'e[d].begin()' because 'e[d]' is empty.\n",
|
ASSERT_EQUALS("[test.cpp:9]: (error) Out of bounds access in expression 'e[d].begin()' because 'e[d]' is empty.\n",
|
||||||
errout.str());
|
errout.str());
|
||||||
|
|
||||||
|
// #10151
|
||||||
|
check("std::set<int>::iterator f(std::set<int>& s) {\n"
|
||||||
|
"for (auto it = s.begin(); it != s.end(); ++it)\n"
|
||||||
|
" if (*it == 42)\n"
|
||||||
|
" return s.erase(it);\n"
|
||||||
|
" return s.end();\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void dereferenceInvalidIterator2() {
|
void dereferenceInvalidIterator2() {
|
||||||
|
|
Loading…
Reference in New Issue