Sample test case that shows the problem. If the uninitialized parameter is first or second (func1), cppcheck flags it, but 3rd or later in the parameter list (func2) and no warning is emitted.
#include <stddef.h> static int func1(bool * result, size_t * buflen) { int newTotal = 5; if (*result && *buflen >= newTotal) newTotal += 1; return newTotal; } static int func2(bool * result, int num, int num2, size_t * buflen) { int newTotal = 5; if (*result && *buflen >= newTotal) newTotal += 1; return newTotal; } int main() { size_t bytesCopied; bool copied_all = true; int result1 = func1(&copied_all, &bytesCopied); // proper warning emitted int result2 = func2(&copied_all, 5, 6, &bytesCopied); // no warning emitted return result1 + result2; }
Thanks! I created this ticket: https://trac.cppcheck.net/ticket/9631
For information, I am hoping that the new "bug hunting" analysis will detect all uninitialized variables in the near future.
Log in to post a comment.
Sample test case that shows the problem. If the uninitialized parameter is first or second (func1), cppcheck flags it, but 3rd or later in the parameter list (func2) and no warning is emitted.
Thanks! I created this ticket: https://trac.cppcheck.net/ticket/9631
For information, I am hoping that the new "bug hunting" analysis will detect all uninitialized variables in the near future.