Hi, I found an inconsistent behavior in the resourceLeak detector. Please see the two programs below. Cppcheck should report consistent resourceLeak warnings for both programs. However, it reports a warning for the first program but does not report any warning for the second one. Therefore, I believe this is inconsistent behavior. First Program #include <stdio.h> int main() { const FILE *a = fopen("good.c", "r"); if (!a) return 0; return 0; } Second Program #include <cstdio> auto main() -> int {...
Hi, I found an inconsistent behavior in the unreadVariable rule. The following two programs are seamntics equivalent. However, CppCheck reported an unreadVariable warning in the first program, but no warnings in the second program. So, I think this is an inconsistent behaviour. The First Program #include <stdio.h> #include <string.h> int main() { char str[20]; for (int i = 0; i < 16; ++i) str[i] = "0123456789abcdef"[i]; return 0; } The Second Program #include <stdio.h> int main() { char str[20];...
Hi, I found inconsistent behavior in Cppcheck when analyzing the following two equivalent programs. Cppcheck reports a warning for the first program, but no warning for the second one. I believe this is a false negative. First Program with a Warning #include <stdio.h> int main() { const FILE *a = fopen("good.c", "r"); if (!a) return 0; return 0; } Second Program without Warnings #include <stdio.h> int main() { const auto a = fopen("good.c", "r"); if (!a) return 0; return 0; } Version: Cppcheck 2.22...
Thank you! I verified it with a newer version and Cppcheck caught the warning. It's indeed an old bug.
Hi, I found an inconsistent behavior in the autoVariables checker. The following two cases are semantically equivalent. However, cppcheck correctly flags the first program with an autoVariables warning, while missing the issue in the second program. Therefore, I believe this is a false negative bug. static void foo(int **a) { int b = 1; *a = &b; } int main() { int *c; foo(&c); return 0; } static void foo(int **a) { auto b = 1; *a = &b; } int main() { int *c; foo(&c); return 0; } Version: 2.19.0
Hi, I found a false negative regarding the rule AccessMoved. In the following program, cppcheck should have reported a AccessMoved warning at line 5 or 6 because static_cast<std::string&&>(s) is equivalent to std::move(s). However, actually it reported no warnings. So I believe this is a false negative. void foo(std::string); int main() { std::string s = "deadbeef"; foo(static_cast<std::string&&>(s)); std::cout << s << std::endl; return 0; } Version: 2.19.0
Hi, I found a false negative regarding the rule AccessMoved. In the following program, cppcheck should have reported a AccessMoved warning at line 5 or 6 because static_cast<std::string&&>(s) is equivalent to std::move(s). However, actually it reported no warnings. So I believe this is a false negative. void foo(std::string); int main() { std::string s = "deadbeef"; foo(static_cast<std::string&&>(s)); std::cout << s << std::endl; return 0; } Version: 2.19.0