From 5ff8955dbe10ab96838797bacb7a03aa00284518 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:49:11 +0200 Subject: [PATCH] Fix #11862 FP truncLongCastAssignment with increment (#5290) --- lib/checktype.cpp | 2 +- test/testtype.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/checktype.cpp b/lib/checktype.cpp index 6f793273392..3384bf69b5e 100644 --- a/lib/checktype.cpp +++ b/lib/checktype.cpp @@ -317,7 +317,7 @@ void CheckType::checkLongCast() // Assignments.. for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) { - if (tok->str() != "=" || !Token::Match(tok->astOperand2(), "*|<<")) + if (tok->str() != "=" || !Token::Match(tok->astOperand2(), "*|<<") || tok->astOperand2()->isUnaryOp("*")) continue; if (tok->astOperand2()->hasKnownIntValue()) { diff --git a/test/testtype.cpp b/test/testtype.cpp index c49ef7aae31..3d84c618024 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -367,6 +367,11 @@ class TestType : public TestFixture { "}\n", settings); ASSERT_EQUALS("[test.cpp:2]: (style) float result is returned as double value. If the return value is double to avoid loss of information, then you have loss of information.\n", errout.str()); + + check("void f(int* p) {\n" // #11862 + " long long j = *(p++);\n" + "}\n", settings); + ASSERT_EQUALS("", errout.str()); } void longCastReturn() {