Bug 39545 is an x86_64 ABI issue relating to the handling of structures with flexible array members in function call and return. It seems likely this corner case has bugs (and incompatibilities with other implementations) for other targets as well. There should be gcc.dg/compat tests specifically testing the ABI when structures with flexible array members, and unions containing such structures, are passed to or returned from functions (including passing through ... and va_arg), covering various cases for the types of the initial elements and the flexible array members. If we believe that [0] arrays (the old GNU extension) at the ends of structures should be passed identically to [] arrays (C99 flexible array members), which is probably a good idea, then there should be tests of this as well.
Flexible array member isn't allowed in union: [hjl@gnu-34 pr39545]$ cat u-1.i union line { int length; char contents[]; }; void foo (union line); union line bar () { union line x; x.length = sizeof (union line); foo (x); return x; } [hjl@gnu-34 pr39545]$ gcc -S u-1.i u-1.i:3: error: flexible array member in union [hjl@gnu-34 pr39545]$
Subject: Re: compat tests for flexible array members On Wed, 25 Mar 2009, hjl dot tools at gmail dot com wrote: > Flexible array member isn't allowed in union: However, a union may contain a structure that in turn contains a flexible array member. And a union may contain a union containing such a structure, and so on.
Confirmed.