From eb072800752cc4c04f3edf401ba9883c51710395 Mon Sep 17 00:00:00 2001 From: Paul Fultz II Date: Wed, 12 Sep 2018 10:33:53 -0500 Subject: [PATCH] Fix issue 8743: FP when derefencing iterators (#1376) --- lib/checkstl.cpp | 2 ++ test/teststl.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 4ca021439..491ab7a2c 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -457,6 +457,8 @@ static const Token * getIteratorExpression(const Token * tok) { if (!tok) return nullptr; + if (tok->isUnaryOp("*")) + return nullptr; if (!tok->isName()) { const Token *iter1 = getIteratorExpression(tok->astOperand1()); if (iter1) diff --git a/test/teststl.cpp b/test/teststl.cpp index 688503bfc..c10435b69 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -709,6 +709,13 @@ private: " if (begin(a).x == begin(b).x) {}\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void f() {\n" + " std::list a;\n" + " std::list b;\n" + " if (*a.begin() == *b.begin()) {}\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void iteratorSameExpression() {