This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 09/06/2016 10:40 PM, Joseph Myers wrote:
On Tue, 6 Sep 2016, Paul Eggert wrote:One way to correct the code is to increase malloc's argument up to a multiple of alignof(max_align_t). (One cannot portably use alignof(struct s) due toSounds like a defect in C11 to me - none of the examples of flexible array members anticipate needing to add to the size to allow for tail padding with unknown alignment requirements.
I agree, this is a defect in C99 and C11. The language hasn't changed since C99, and C99 has the same issue because it's unrelated to alignment specifiers. It's a confusion between struct sizes (which are multiples of the struct alignment) and object sizes (which are not necessarily so).
I have reopened PR66661 with a more elaborate test case which shows that GCC packs objects more tightly than the struct alignment would permit.
Thanks, Florian
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |