On Fri, 19 May 2023, Qing Zhao via Gcc-patches wrote:
> +GCC extension accepts a structure containing an ISO C99 @dfn{flexible array
"The GCC extension" or "A GCC extension".
> +@item
> +A structure containing a C99 flexible array member, or a union containing
> +such a structure, is the middle field of another structure, for example:
There might be more than one middle field, and I think this case also
includes where it's the *first* field - any field other than the last.
> +@smallexample
> +struct flex @{ int length; char data[]; @};
> +
> +struct mid_flex @{ int m; struct flex flex_data; int n; @};
> +@end smallexample
> +
> +In the above, @code{mid_flex.flex_data.data[]} has undefined behavior.
And it's not literally mid_flex.flex_data.data[] that has undefined
behavior, but trying to access a member of that array.
> +Compilers do not handle such case consistently, Any code relying on
"such a case", and "," should be "." at the end of a sentence.
--
Joseph S. Myers
[email protected]