Using the latest cppcheck 2.5 I came across a new false positive I would like to share. With option --enable=all it is reporting knownConditionTrueFalse, where obviously incorrect as my simplified test case proves:
structS {
void*obj;
};staticintfunc(structSa, structSb) {
if(a.obj&&b.obj) {
if(a.obj!=b.obj) {
/* according to cppcheck, we never get here ... */return0;
}
return1;
}
return1;
}
intmain(intac, char**av) {
structSa;structSb;a.obj=(void*)1;b.obj=(void*)2;returnfunc(a,b);
}
Using the latest
cppcheck 2.5
I came across a new false positive I would like to share. With option--enable=all
it is reportingknownConditionTrueFalse
, where obviously incorrect as my simplified test case proves:But the code compiles fine and indeed returns
0
fromfunc
:It'd be great if someone could have a look into this & file a bug report for this regression.
Thanks!
Last edit: Jo 2021-07-16
Here's another variant of possibly the same (?) issue:
again: code compiles fine and proves that
cppcheck
is reporting a false positive here:Last edit: Jo 2021-07-16