I found current clang reports a warning
warning: Passed-by-value struct argument contains uninitialized data (e.g., field: '') [core.CallAndMessage]
when do static analysis on the following code (processed as C source file) :
// code piece 1 typedef struct{ unsigned x :3; unsigned :29; unsigned y; }A; extern void func1(A a); void func2(){ A a = {0}; func1(a); } }
According C or C++ standards, "unnamed bit-fields are skipped during aggregate initialization." Unnamed bit-fields can not be explicitly initialized, and taking no explicitly initialization will not cause problems since they would not be used.
With this patch, no warning will be reported on the above code. And the checker will still be effective to real warning. e.g. it will report " warning: Passed-by-value struct argument contains uninitialized data (e.g., field: 'y') [core.CallAndMessage]" on following code:
typedef struct{ unsigned x :3; unsigned :29; unsigned y; }A; extern void func1(A a); void func2(){ A a; a.x = 0; func1(a); } }