diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 9891e27fe..600316d8f 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -150,7 +150,13 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set if (var.isArray()) { Alloc alloc = ARRAY; const std::map variableValue; - checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue); + bool init = false; + for (const Token *parent = var.nameToken(); parent; parent = parent->astParent()) { + if (parent->str() == "=") + init = true; + } + if (!init) + checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue); continue; } if (stdtype || var.isPointer()) { diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 2557aaaab..3f947cda5 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -4003,6 +4003,12 @@ private: " dostuff(*a);\n" "}"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar("void f() {\n" + " void (*fp[1]) (void) = {function1};\n" + " (*fp[0])();\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void deadPointer() {