diff --git a/lib/checkother.cpp b/lib/checkother.cpp index d7ed416b0..468945f2f 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1361,6 +1361,9 @@ static const Token *uninitvar_checkscope(const Token * const tokens, const Token if (tok->varId() == varid) { + if (array && !Token::simpleMatch(tok->next(), "[")) + continue; + if (Token::simpleMatch(tok->previous(), "return")) return tok; diff --git a/test/testother.cpp b/test/testother.cpp index a2e0e7a34..5924eacac 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1108,6 +1108,13 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + checkUninitVar("void f()\n" + "{\n" + " char a[10], *p;\n" + " *(p = a) = 0;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + checkUninitVar("void f()\n" "{\n" " char c[50] = \"\";\n"