diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 274106fe248..9eb148f2954 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2837,6 +2837,8 @@ bool isExpressionChanged(const Token* expr, const Token* start, const Token* end if (vt->type == ValueType::ITERATOR) ++indirect; } + if (Token::Match(tok->astParent(), "%cop%") && tok2->astParent() && tok2->astParent()->isIncDecOp()) + indirect = 0; if (isExpressionChangedAt(tok, tok2, indirect, global, settings, cpp, depth)) return true; } diff --git a/test/teststl.cpp b/test/teststl.cpp index 64acd7027c6..bb9f3ad7b57 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -3033,8 +3033,7 @@ class TestStl : public TestFixture { " }\n" "}"); ASSERT_EQUALS( - "[test.cpp:4] -> [test.cpp:6] -> [test.cpp:3] -> [test.cpp:9]: (error, inconclusive) Using iterator to local container 'vec' that may be invalid.\n" - "[test.cpp:4] -> [test.cpp:9]: (warning) Either the condition 'it!=vec.end()' is redundant or there is possible dereference of an invalid iterator: it.\n", + "[test.cpp:4] -> [test.cpp:6] -> [test.cpp:3] -> [test.cpp:9]: (error, inconclusive) Using iterator to local container 'vec' that may be invalid.\n", errout.str()); }