https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71250

--- Comment #3 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
However, it seems that GCC doesn't support the { 0 } idiom in all cases. For
instance:

#include <pthread.h>

struct { struct { int a; long b; } x; int y; } s = { { 1 }, 1 };

struct { struct { int a; long b; } x; int y; } t = { { 0 }, 1 };

struct { struct { pthread_rwlock_t a; long b; } x; int y; } u = { { 0 }, 1 };

The first structure initialization triggers the warning as expected:

tst.c:3:17: warning: missing initializer for field ‘b’ of ‘struct <anonymous>’
-Wmissing-field-initializers]
 struct { struct { int a; long b; } x; int y; } s = { { 1 }, 1 };
                 ^
tst.c:3:31: note: ‘b’ declared here
 struct { struct { int a; long b; } x; int y; } s = { { 1 }, 1 };
                               ^

The second one doesn't trigger any warning due to the use of the idiom.

But the third one triggers the following warning, though the same idiom is
used:

tst.c:7:65: warning: missing braces around initializer [-Wmissing-braces]
 struct { struct { pthread_rwlock_t a; long b; } x; int y; } u = { { 0 }, 1 };
                                                                 ^
tst.c:7:65: note: (near initialization for ‘u’)

Reply via email to