Compiling with gcc -std=c99 -Wextra
this piece of code:
#include <stdio.h>struct T { int a; int *b; int c;};int main(void){ struct T t = {.b = ((int []){1, 1})}; printf("%d\n", t.b[1]); return 0;}
Is giving me a warning:
demo.c:11:12: warning: missing initializer for field ‘c’ of ‘struct T’ [-Wmissing-field-initializers] struct T t = {.b = ((int []){1, 1})}; ^demo.c:6:9: note: ‘c’ declared here int c; ^
But designated initializers are supposed to initialize to zero the rest of the members even if they are ommited.
Why the warning? (clang
compiles the same piece of code without warnings)
gcc version 6.3.0 20170516 (Debian 6.3.0-18) clang version 3.8.1-24 (tags/RELEASE_381/final)