diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 7d755ed72..90e3268a3 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1084,6 +1084,8 @@ void CheckUninitVar::checkScope(const Scope* scope) } while (tok && tok->str() != ";") tok = tok->next(); + if (Token::findsimplematch(i->typeStartToken(), "=", tok)) + continue; if (stdtype || i->isPointer()) checkScopeForVariable(scope, tok, *i, NULL, NULL, ""); if (Token::Match(i->typeStartToken(), "struct %type% %var% ;")) { diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index b86b742be..e92e133d6 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2350,6 +2350,11 @@ private: " x((A)(B)&a);\n" "}"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar2("void f() {\n" // #4717 - ({}) + " int a = ({ long b = (long)(123); 2 + b; });\n" + "}", "test.c"); + ASSERT_EQUALS("", errout.str()); } // #3869 - reference variable