Re: [PATCH] 2.5 fast poll on ppc64

Richard Henderson
2002-12-27T00:06:41Z

On Thu, Dec 26, 2002 at 09:55:15PM +0100, Mikael Pettersson wrote:
> >I would agree, but there is a special restriction on offsetof() and
> >sizeof() of structures with flexible array members: section 6.7.2.1,
> >clause 16:
> >
> >First, the size of the structure shall be equal to the offset of the
> >last element of an otherwise identical structure that replaces the
> >flexible array member with an array of unspecified length.
[...]
> Oh dear. I checked my C9x draft copy and you seem to be right.
> The standard states that sizeof(struct a1) == offsetof(struct a1, c),
> but both gcc (2.95.3 and 3.2) and Intel's icc (7.0) get it wrong on x86:
> they make sizeof(struct a1) == 8 but offsetof(struct a1, c) == 6.

Indeed, *every* compiler that supports flexible array members
does it this way. On the gcc lists we've conjectured that this
will wind up being a Defect Report, and so have elected not to
change anything for the nonce.

That said, you should also note that "struct S foo[0]" is *not*
a flexible array member; "struct S foo[]" is. The former is
gcc's zero-length array extension. There are subtle differences
between the two features. See the gcc docs for details.

r~