Messages in this thread | | | Date | Thu, 26 Dec 2002 16:14:44 -0800 | From | Richard Henderson <> | Subject | Re: [PATCH] 2.5 fast poll on ppc64 |
| |
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~ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |