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:
struct S {
void* obj;
};
static int func(struct S a, struct S b) {
if (a.obj && b.obj) {
if (a.obj != b.obj) {
/* according to cppcheck, we never get here ... */ return 0; } return 1; } return 1;}int main(int ac, char** av) {
struct S a;
struct S b;
a.obj = (void*)1;
b.obj = (void*)2;
return func(a,b);
}
Using the latest
cppcheck 2.5I came across a new false positive I would like to share. With option--enable=allit is reportingknownConditionTrueFalse, where obviously incorrect as my simplified test case proves:But the code compiles fine and indeed returns
0fromfunc: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
cppcheckis reporting a false positive here:Last edit: Jo 2021-07-16