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

--- Comment #1 from qinzhao at gcc dot gnu.org ---
in the routine "finish_struct" of c-decl.cc, we have:

 9660       if (warn_flex_array_member_not_at_end
 9661           && !is_last_field
 9662           && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))
 9663           && TYPE_INCLUDES_FLEXARRAY (TREE_TYPE (x)))
 9664         warning_at (DECL_SOURCE_LOCATION (x),
 9665                     OPT_Wflex_array_member_not_at_end,
 9666                     "structure containing a flexible array member"
 9667                     " is not at the end of another structure");

when I debugged the small testing case in gdb in the above code, I observed
that:

when handling the field "x" in struct "Q", the TYPE_INCLUDES_FLEXARRAY
(TREE_TYPE (x))) is FALSE. 

typedef struct X XX;

struct X {
    int length;
    int a[];
};

struct Q {
    XX x;
    int plug;
};

So, I suspect that the root cause is: the TYPE_INCLUDES_FLEXARRAY marking of
the struct X was not copied to its aliased type "XX". 

need to figure out how to set the TYPE_INCLUDES_FLEXARRAY marking of XX
correctly based on "struct X"

Reply via email to