diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 91bfd0dfa..96f736b4f 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -968,7 +968,7 @@ void CheckStl::missingComparison() incrementToken = tok3; else if (tok3->varId() == iteratorId && Token::Match(tok3->next(), "!=|==")) incrementToken = 0; - else if (tok3->str() == "break") + else if (tok3->str() == "break" || tok3->str() == "return") incrementToken = 0; } if (incrementToken) diff --git a/test/teststl.cpp b/test/teststl.cpp index aeabd69fa..354907310 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -1118,6 +1118,16 @@ private: " }\n" "}"); ASSERT_EQUALS("", errout.str()); + + check("function f1(std::list &l1) {\n" + " for(std::list::iterator i = l1.begin(); i != l1.end(); i++) {\n" + " if (*i == 44) {\n" + " l1.insert(++i, 55);\n" + " return;\n" + " }\n" + " }\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void missingInnerComparison5()