Consider, at file scope,
struct {void *foo, *bar;} X = {.foo=NULL,};
bar will get all-bits-zero
That is incorrect. Bar will be initialized to null, just like foo,
whose initializer is redundant since X is a static object.
Static objects with no explicit initializers are are given proper zero
values of their type. Pointers are null, floating-point objects have
value 0.0, and integers are 0.
Even if you move X to a block scope and give it automatic instead of
static storage, both foo and bar will still be initialized to null.
That's because aggregate such as a structure or array is either fully
initialized, or not at all; there is no partial initialization. If any
member has an initializer, whether designated or classic style, all of
the other members are also initialized. Any members which don't have
an initializer get a zero.
{
// no members are initialized
struct s a;
// first member gets explicit zero
// all other members, implicit zero
struct s b = { 0 };
// ...
}
which AFAIK officially ain't necessarily a NULL.
You mean ``null''. ``NULL'' is a preprocessor symbol in C.
Now, how bad is the assumption that X.bar==NULL?
It's a half-decent assumption as far as assumptions go.