Está garantizado que ser 0 si está parcialmente inicializado, al igual que inicializadores de matriz. Si no está inicializado, será desconocido.
struct T t; // t.x, t.y will NOT be initialized to 0 (not guaranteed to)
struct T t = {42}; // t.y will be initialized to 0.
mismo modo:
int x[10]; // Won't be initialized.
int x[10] = {1}; // initialized to {1,0,0,...}
muestra:
// a.c
struct T { int x, y };
extern void f(void*);
void partialInitialization() {
struct T t = {42};
f(&t);
}
void noInitialization() {
struct T t;
f(&t);
}
// Compile with: gcc -O2 -S a.c
// a.s:
; ...
partialInitialzation:
; ...
; movl $0, -4(%ebp) ;;;; initializes t.y to 0.
; movl $42, -8(%ebp)
; ...
noInitialization:
; ... ; Nothing related to initialization. It just allocates memory on stack.
¿Se inicializarán los punteros a NULL correctamente? – user10607