From 4a119640c57e8ec4984adccf7e2991eaf221e386 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 9 Sep 2019 17:20:03 +0200 Subject: [PATCH] #8755: Add regression test (#2160) * #8755: Add regression test https://trac.cppcheck.net/ticket/8755 False negative: uninitvar not detected * Fixed formatting (runastyle) --- test/testuninitvar.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 0d3eb8f7f..091882598 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -4252,6 +4252,18 @@ private: " return (*sink)[0];\n" "}"); ASSERT_EQUALS("", errout.str()); + + // Ticket #8755 + valueFlowUninit("void f(int b) {\n" + " int a;\n" + " if (b == 10)\n" + " a = 1;\n" + " if (b == 13)\n" + " a = 1;\n" + " if (b == 'x') {}\n" + " if (a) {}\n" + "}"); + ASSERT_EQUALS("[test.cpp:8]: (error) Uninitialized variable: a\n", errout.str()); } void uninitvar_ipa() {