From 415cbc63c3225d77d467e0ef96a328c0399766a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 27 Sep 2010 19:26:09 +0200 Subject: [PATCH] Fixed #2066 (false positive: uninitialized variable when initializing through function pointer) --- lib/checkother.cpp | 2 +- test/testother.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 9c58fdd63..6e99e8398 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3291,7 +3291,7 @@ private: } } - else if (Token::Match(&tok, "%var% (") && uvarFunctions.find(tok.str()) == uvarFunctions.end()) + if (Token::Match(&tok, "%var% (") && uvarFunctions.find(tok.str()) == uvarFunctions.end()) { if (Token::simpleMatch(&tok, "sizeof (")) return tok.next()->link(); diff --git a/test/testother.cpp b/test/testother.cpp index e623fff83..461a087df 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2274,6 +2274,15 @@ private: " return x;\n" "}"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar("void (*init)(char *str);\n" + "\n" + "char x() {\n" + " char cmd[10];\n" + " init(cmd);\n" + " return cmd[0];\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); }