Of course the sample program itself is silly and does not serve any real purpose, it is just the simplest piece of code that I was able to trigger this false positive with.
Applying any of the following changes prevents the false positive from being triggered:
git bisect claims that commit bd7e915c208219d6a5e3efca40168d31f9c0248c, i.e. pull request #2878, is the culprit. I also carried out an additional bisect on that pull request's branch (pfultz2/valueflow-generic-reverse) and it pointed at commit 5c75d1f0c2b23f74694318a060b43e3724df2b73 ("Add support for reassignment").
Please let me know if any further information and/or experiments would help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi there,
Thank you for your work on cppcheck!
For the following C program:
cppcheck 2.3 (with
--enable=warning
) reports:Of course the sample program itself is silly and does not serve any real purpose, it is just the simplest piece of code that I was able to trigger this false positive with.
Applying any of the following changes prevents the false positive from being triggered:
if (quotient != 0) { ... }
blockargc /= 2;
lineargc /= 2; quotient = argc;
withquotient = argc / 2;
git bisect
claims that commit bd7e915c208219d6a5e3efca40168d31f9c0248c, i.e. pull request #2878, is the culprit. I also carried out an additional bisect on that pull request's branch (pfultz2/valueflow-generic-reverse
) and it pointed at commit 5c75d1f0c2b23f74694318a060b43e3724df2b73 ("Add support for reassignment").Please let me know if any further information and/or experiments would help.
Thanks! This is a great report we should have the info we need. I have created this ticket:
https://trac.cppcheck.net/ticket/10049