diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index f7246445e..71d606d8b 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1208,13 +1208,14 @@ void CheckUninitVar::valueFlowUninit() if (!scope->isExecutable()) continue; for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) { - if (!tok->variable()) + if (!tok->variable() || tok->values().size() != 1U) continue; - if (tok->values().size() != 1U || tok->values().front().valueType != ValueFlow::Value::UNINIT) + const ValueFlow::Value &v = tok->values().front(); + if (v.valueType != ValueFlow::Value::UNINIT || v.inconclusive) continue; if (!isVariableUsage(tok, tok->variable()->isPointer(), NO_ALLOC)) continue; - uninitvarError(tok,tok->str()); + uninitvarError(tok, tok->str()); } } } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index c25971e19..72d2c9c28 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -3816,6 +3816,13 @@ private: " switch (x) {}\n" "}"); ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: x\n", errout.str()); + + checkUninitVar("int f() {\n" + " int x;\n" + " init(x);\n" + " return x;\n" // TODO: inconclusive ? + "}"); + ASSERT_EQUALS("", errout.str()); } void isVariableUsageDeref() {