Skip to content

Commit 5ff8955

Browse files
Fix #11862 FP truncLongCastAssignment with increment (#5290)
1 parent da6c39e commit 5ff8955

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/checktype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ void CheckType::checkLongCast()
317317

318318
// Assignments..
319319
for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) {
320-
if (tok->str() != "=" || !Token::Match(tok->astOperand2(), "*|<<"))
320+
if (tok->str() != "=" || !Token::Match(tok->astOperand2(), "*|<<") || tok->astOperand2()->isUnaryOp("*"))
321321
continue;
322322

323323
if (tok->astOperand2()->hasKnownIntValue()) {

test/testtype.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,11 @@ class TestType : public TestFixture {
367367
"}\n", settings);
368368
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",
369369
errout.str());
370+
371+
check("void f(int* p) {\n" // #11862
372+
" long long j = *(p++);\n"
373+
"}\n", settings);
374+
ASSERT_EQUALS("", errout.str());
370375
}
371376

372377
void longCastReturn() {

0 commit comments

Comments
 (0)