diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 4e9251a0c..a907e38c1 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1311,7 +1311,7 @@ bool CheckUninitVar::isVariableUsage(const Scope* scope, const Token *vartok, bo argStart = argStart->previous(); if (argStart->isStandardType() && Token::Match(argStart, "%type% %var% [,)]")) return true; - if (Token::Match(argStart, "const")) + if (!(pointer && address) && Token::Match(argStart, "const")) return true; } } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 6a91a12e7..5c6123b02 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2375,7 +2375,7 @@ private: ASSERT_EQUALS("[test.c:3]: (error) Uninitialized variable: a\n", errout.str()); } - // Handling of unknown types. Assume they are POD in C. + // Handling of function calls void uninitvar2_func() { checkUninitVar2("void a(char c);\n" "void b() {\n" @@ -2411,6 +2411,13 @@ private: " a(&abc);\n" "}", "test.c"); ASSERT_EQUALS("[test.c:4]: (error) Uninitialized variable: abc\n", errout.str()); + + checkUninitVar2("void a(const char **p);\n" + "void b() {\n" + " const char *s;\n" + " a(&s);\n" + "}"); + ASSERT_EQUALS("", errout.str()); } };