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>staticintfunc1(bool*result,size_t*buflen){intnewTotal=5;if(*result&&*buflen>=newTotal)newTotal+=1;returnnewTotal;}staticintfunc2(bool*result,intnum,intnum2,size_t*buflen){intnewTotal=5;if(*result&&*buflen>=newTotal)newTotal+=1;returnnewTotal;}intmain(){size_tbytesCopied;boolcopied_all=true;intresult1=func1(&copied_all,&bytesCopied);// proper warning emittedintresult2=func2(&copied_all,5,6,&bytesCopied);// no warning emittedreturnresult1+result2;}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.