Bug 39550 - compat tests for flexible array members
Summary: compat tests for flexible array members
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: testsuite (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: flexmembers
  Show dependency treegraph
 
Reported: 2009-03-24 22:20 UTC by Joseph S. Myers
Modified: 2016-02-05 22:13 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-01-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph S. Myers 2009-03-24 22:20:57 UTC
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.
Comment 1 H.J. Lu 2009-03-25 00:40:16 UTC
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]$ 
Comment 2 jsm-csl@polyomino.org.uk 2009-03-25 00:45:38 UTC
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.

Comment 3 Andrew Pinski 2012-01-08 21:47:51 UTC
Confirmed.