diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 55ff70960..d45209c47 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -6820,6 +6820,8 @@ bool productParams(const std::unordered_map>& v for (auto arg:args) { if (value.path != 0) { for (const auto& q:arg) { + if (q.first == p.first) + continue; if (q.second.path == 0) continue; if (q.second.path != value.path) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index dc09943a0..3d48a01fd 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -4398,6 +4398,17 @@ private: "}\n"; ASSERT_EQUALS(true, testValueOfX(code, 7U, 0)); ASSERT_EQUALS(false, testValueOfXKnown(code, 7U, 0)); + + code = "int f(int i) {\n" + " int x = abs(i);\n" + " return x;\n" + "}\n" + "void g() {\n" + " f(1);\n" + " f(0);\n" + "}\n"; + ASSERT_EQUALS(true, testValueOfX(code, 3U, 1)); + ASSERT_EQUALS(true, testValueOfX(code, 3U, 0)); } void valueFlowFunctionReturn() { const char *code;