diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 167f6de48..3ade624d7 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1203,7 +1203,7 @@ static void valueFlowSubFunction(TokenList *tokenlist, ErrorLogger *errorLogger, // passing value(s) to function if (Token::Match(tok, "[(,] %var% [,)]") && !tok->next()->values.empty()) argvalues = tok->next()->values; - else if (Token::Match(tok, "[(,] %num% [,)]")) { + else if (Token::Match(tok, "[(,] %num% [,)]") && MathLib::isInt(tok->strAt(1))) { argvalues.clear(); argvalues.push_back(ValueFlow::Value(MathLib::toLongNumber(tok->next()->str()))); } else { diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 352b56546..ac15c79f4 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -918,6 +918,13 @@ private: "void f2() { f1(0); }"; ASSERT_EQUALS(true, testValueOfX(code, 2U, 0)); ASSERT_EQUALS(false, testValueOfX(code, 3U, 0)); + + // #5861 - fp with float + code = "void f1(float x) {\n" + " return 1.0 / x;\n" + "}\n" + "void f2() { f1(0.5); }"; + ASSERT_EQUALS(false, testValueOfX(code, 2U, 0)); } };