From fbfe5a4bd1aaf1f29197ce1206cbd7df78c60317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 27 Dec 2009 09:27:05 +0100 Subject: [PATCH] Fixed #1153 (False positive: uninitialized data for reinterpret_cast) --- lib/checkother.cpp | 2 +- test/testother.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index af6fe1bc4..73c7a8993 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1415,7 +1415,7 @@ private: CheckUninitVar *c = dynamic_cast(*it); if (c && c->varId == varid) { - if (mode == 0 && c->array) + if (mode == 0 && (c->array || (c->pointer && c->alloc))) continue; if (mode == 2 && !c->pointer) continue; diff --git a/test/testother.cpp b/test/testother.cpp index 0ea7f141d..31de8f0a1 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1080,6 +1080,13 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + checkUninitVar("void foo()\n" + "{\n" + " char *buf = malloc(100);\n" + " struct ABC *abc = buf;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + // goto.. checkUninitVar("void foo(int x)\n" "{\n"