diff --git a/tccgen.c b/tccgen.c index 01afd89e..93e4b346 100644 --- a/tccgen.c +++ b/tccgen.c @@ -7660,6 +7660,10 @@ static void decl_initializer(init_params *p, CType *type, unsigned long c, int f } len = 0; + /* GNU extension: if the initializer is empty for a flex array, + it's size is zero. We won't enter the loop, so set the size + now. */ + decl_design_flex(p, s, len); while (tok != '}' || (flags & DIF_HAVE_ELEM)) { len = decl_designator(p, type, c, &f, flags, len); flags &= ~DIF_HAVE_ELEM; diff --git a/tests/tests2/80_flexarray.c b/tests/tests2/80_flexarray.c index 1fc1a60a..864d4298 100644 --- a/tests/tests2/80_flexarray.c +++ b/tests/tests2/80_flexarray.c @@ -15,6 +15,7 @@ int f1int (void) { struct wint q = {"bugs"}; return !s[0]; } +int empty[] = {}; // GNU extension int main (void) { char s[9]="nonono"; static struct wchar q = {"bugs", {'c'}};