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

--- Comment #7 from qinzhao at gcc dot gnu.org ---
from the standard:

A structure or union shall not contain a member with incomplete or function
type (hence, a structure shall not contain an instance of itself, but may
contain a pointer to an instance of itself), except that the last member of a
structure with more than one named member may have incomplete array type; such
a structure (and any union containing, possibly recursively, a member that is
such a structure) shall not be a member of a structure or an element of an
array.

as a result, if you add -Wpedantic to the compilation line:

[opc@qinzhao-ol8u3-x86 101832]$ sh t
/home/opc/Install/latest-d/bin/gcc -O1 -Wpedantic t.c
t.c:30:18: warning: invalid use of structure with flexible array member
[-Wpedantic]
   30 |     struct nlmsg msg;
      |                  ^~~


However, looks like that GCC extension allow such usage, but I am not sure
whether there is any documentation on such extension?

Reply via email to