diff --git a/lib/reverseanalyzer.cpp b/lib/reverseanalyzer.cpp index dd8c8c1be..592e34afd 100644 --- a/lib/reverseanalyzer.cpp +++ b/lib/reverseanalyzer.cpp @@ -95,12 +95,6 @@ struct ReverseTraversal { bool checkThen, checkElse; std::tie(checkThen, checkElse) = evalCond(condTok); - if (!checkThen && !checkElse) { - Analyzer::Action action = analyzeRecursive(condTok); - if (action.isRead() || action.isModified()) - return parent; - } - if (parent->str() == "?") { if (checkElse && opSide == 1) return parent; diff --git a/test/teststl.cpp b/test/teststl.cpp index f31ba9367..686b7bcf2 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -3787,6 +3787,12 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (warning) Either the condition '(i+1)!=s.end()' is redundant or there is possible dereference of an invalid iterator: i+2.\n", errout.str()); + check("void f(int v, std::map &items) {\n" + " for (auto it = items.begin(); it != items.end();)\n" + " (it->first == v) ? it = items.erase(it) : ++it;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + check("void f(std::string s) {\n" " for (std::string::const_iterator i = s.begin(); i != s.end(); ++i) {\n" " if (i != s.end() && (i + 1) != s.end() && *(i + 1) == *i) {\n"