lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Thu, May 14, 2020 at 2:36 PM Philippe Verdy <verdyp@gmail.com> wrote:
Le mer. 13 mai 2020 à 19:20, Massimo Sala <massimo.sala.71@gmail.com> a écrit :
I consider this article, written by Gnu C authors, enlightening on the topic:

I have to disagree to this statement made in that article: "Although the size of a zero-length array is zero, an array member of this kind may increase the size of the enclosing type as a result of tail padding."

Because I don't see which kind of tail padding would occur after a zero-length array (which does not change at all the size of existing enclosing type, except for aligning the first member of the zero-length array: this is not *trailing* padding, but *leading* padding, i.e. influences the offset of the 1st element that could be in the variable-size array; but when the zero-length array has base type "char", its alignment is 1 by definition, meaning that multiple members of type non-array char are just packed at successive offsets+1:

It's padding the tail of the struct, even if it's padding the lead of the array.

/s/ Adam
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org