Hi, I found a false negative regarding the rule AssignmentAddressToInteger.
AssignmentAddressToInteger
Cppcheck misses the pointer-to-integer conversion when it is written as a compound assignment.
int f(int *p) { int a = 0; a += p; return a + 4; }
Cppcheck does not report AssignmentAddressToInteger. Replacing a += p with a = a + p produces the warning.
a += p
a = a + p
Cppcheck should also report the pointer-to-integer conversion in the compound assignment.
The issue was reproduced with:
cppcheck --output-format=xmlv2 --enable=all assignment_compound.c
Version: 2.21.0
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15075
Log in to post a comment.
Hi, I found a false negative regarding the rule
AssignmentAddressToInteger.Cppcheck misses the pointer-to-integer conversion when it is written as a compound assignment.
Actual result
Cppcheck does not report
AssignmentAddressToInteger. Replacinga += pwitha = a + pproduces the warning.Expected result
Cppcheck should also report the pointer-to-integer conversion in the compound assignment.
Verification
The issue was reproduced with:
Version: 2.21.0
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15075