Skip to content

Commit

Permalink
Fix #11862 FP truncLongCastAssignment with increment (danmar#5290)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Aug 3, 2023
1 parent da6c39e commit 5ff8955
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checktype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
5 changes: 5 additions & 0 deletions test/testtype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 5ff8955

Please sign in to comment.