Skip to content

Comments

Fix #11389 Do not warn for truncLongCastReturn if operands have known valid int#8192

Merged
danmar merged 4 commits intodanmar:mainfrom
ceJce:fix11389_unnecessary_truncLongCastReturn
Feb 24, 2026
Merged

Fix #11389 Do not warn for truncLongCastReturn if operands have known valid int#8192
danmar merged 4 commits intodanmar:mainfrom
ceJce:fix11389_unnecessary_truncLongCastReturn

Conversation

@ceJce
Copy link
Contributor

@ceJce ceJce commented Feb 9, 2026

This fix handles the first example in ticket, i.e. when the value is known to be a valid int:

long f() {
int n = 1;
return n << 12;
}

Copy link
Owner

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! I would like some test cases. One case where we don't write a false positive.

And verify that we still warn when we want.

@ceJce ceJce force-pushed the fix11389_unnecessary_truncLongCastReturn branch 2 times, most recently from 968f597 to 2c262a0 Compare February 17, 2026 07:55
@ceJce
Copy link
Contributor Author

ceJce commented Feb 17, 2026

thanks! I would like some test cases. One case where we don't write a false positive.

And verify that we still warn when we want.

Tests added.

@ceJce ceJce requested a review from danmar February 18, 2026 08:09
@ceJce ceJce force-pushed the fix11389_unnecessary_truncLongCastReturn branch 2 times, most recently from cf1e453 to 88ba04e Compare February 19, 2026 12:49
@ceJce ceJce force-pushed the fix11389_unnecessary_truncLongCastReturn branch from 88ba04e to 452304d Compare February 20, 2026 09:03
@ceJce ceJce force-pushed the fix11389_unnecessary_truncLongCastReturn branch from 452304d to 976db09 Compare February 20, 2026 11:39
@sonarqubecloud
Copy link

@danmar danmar merged commit bd33cf5 into danmar:main Feb 24, 2026
68 of 72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants