http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57180

--- Comment #3 from Mikael Pettersson <mikpe at it dot uu.se> ---
According to
<http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Zero-Length.html#Zero-Length>,
arrays of structures with trailing flex arrays are invalid and rejected. The
page also gives an example of that, but changing it to use a char array with
either a string literal initializer or a { } one shows that only the { } form
is rejected:

> cat pr57180-2.c
struct foo { int x; char y[]; };
struct foo a[1] = { { 1, "ab" } };
struct foo b[1] = { { 1, { 'a', 'b', '\0' } } };
> gcc -Wall -S pr57180-2.c
pr57180-2.c:3:8: error: initialization of flexible array member in a nested
context
 struct foo b[1] = { { 1, { 'a', 'b', '\0' } } };
        ^
pr57180-2.c:3:8: error: (near initialization for 'b[0].y')

Accepting the a[] initializer while rejecting the b[] one seems broken.

Reply via email to