diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index d1d10082821..047915a44b0 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -690,6 +690,8 @@ static std::vector getAddressContainer(const Token* tok) { if (Token::simpleMatch(tok, "[") && tok->astOperand1()) return { tok->astOperand1() }; + while (Token::simpleMatch(tok, "::") && tok->astOperand2()) + tok = tok->astOperand2(); std::vector values = ValueFlow::getLifetimeObjValues(tok, /*inconclusive*/ false); std::vector res; for (const auto& v : values) { diff --git a/test/teststl.cpp b/test/teststl.cpp index 252239307a0..f7bf96fb034 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -2204,6 +2204,16 @@ class TestStl : public TestFixture { " a.erase(*it);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("namespace N {\n" // #12443 + " std::vector v;\n" + "}\n" + "using namespace N;\n" + "void f() {\n" + " auto it = std::find(v.begin(), v.end(), 0);\n" + " if (it != N::v.end()) {}\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void eraseIteratorOutOfBounds() {