https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94132

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

"A structure containing a flexible array member, or a union containing such a
structure (possibly recursively), may not be a member of a structure or an
element of an array. (However, these uses are permitted by GCC as extensions.)"

The C++ compiler implements the stricter rule from ISO C, not the extension.

(In reply to Amir Ansari from comment #2)
> Because I know the flexible array member data isn't dangling. I have
> allocated space immediately following the member that I would like to use.

That's not how you're supposed to do it. You're supposed to dynamically
allocate space for the struct and space after it, not place it inside a larger
structute.

> It has been working perfectly in previous versions.

I'd say it's actually been undefined because G++ allowed pretty much any
nonsense in terms of flexible array members.

Reply via email to