diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index b29ffa302..def045c35 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1054,9 +1054,10 @@ void CheckUninitVar::checkScope(const Scope* scope) bool stdtype = false; const Token* tok = i->typeStartToken(); - for (; tok->str() != ";"; tok = tok->next()) + for (; tok->str() != ";" && tok->str() != "<"; tok = tok->next()) { if (tok->isStandardType()) stdtype = true; + } if (stdtype || i->isPointer()) checkScopeForVariable(tok, *i, NULL); diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 4818d29be..66be4ca34 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2150,6 +2150,14 @@ private: " int a, a2, a2*x; if () ;\n" " )\n" "}\n"); + + // Ticket #3890 - False positive for std::map + checkUninitVar2("void f() {\n" + " std::map x;\n" + " return x;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } // #3869 - reference variable