sizeof struct with flexible array: when did it change?

Liste des GroupesRevenir à cl c  
Sujet : sizeof struct with flexible array: when did it change?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.c
Date : 07. Oct 2024, 03:32:13
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20241006192337.76@kylheku.com>
User-Agent : slrn/pre1.0.4-9 (Linux)
C99 said that the size of a structure that ends in a flexible array
member is the same as the offset of that flexible member in a
similar structure in which the array has some unspecified size.

The latest draft says that the size is calculated as if the flexible
array member were omitted, except that there may be more padding than
the omission would imply.

I can't think of a reasonable interpretation of the original
wording which would allow the size to be other than the offset
of the array, when the array is of a character type.

The current wording clearly does allow the size to go beyond the offset
in that case.

Don't get burned: don't rely on the size of a flexible array struct.
Use the offsetof that flexible member.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Date Sujet#  Auteur
7 Oct 24 * sizeof struct with flexible array: when did it change?6Kaz Kylheku
7 Oct 24 +- Re: sizeof struct with flexible array: when did it change?1Tim Rentsch
7 Oct 24 `* Re: sizeof struct with flexible array: when did it change?4Nick Bowler
8 Oct 24  +* Re: sizeof struct with flexible array: when did it change?2Kaz Kylheku
9 Oct 24  i`- Re: sizeof struct with flexible array: when did it change?1Jeremy Brubaker
14 Oct 24  `- Re: sizeof struct with flexible array: when did it change?1Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal