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

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> ---
On Mon, 19 Sep 2016, msebor at gcc dot gnu.org wrote:

> While testing my patch for C++ bug 71912 and gathering material for WG14 paper
> N2083 I noticed that GCC isn't completely consistent in diagnosing invalid 
> uses
> of flexible array members.  In the following example, it rejects the 
> definition
> of struct Y with a hard error because the flexible array member a is followed
> by another member, j.  But GCC issues only a pedantic warning for the similar
> definition of struct T where the flexible array member defined in a nested
> struct is also followed by another member.  I think it would be better (more
> consistent and safer(*)) if both structs were rejected with an error.

The nested struct is accepted to work with glibc headers, as I noted in 
<https://gcc.gnu.org/ml/gcc-patches/2002-08/msg01149.html>.  gconv.h has

typedef struct __gconv_info
{
  size_t __nsteps;
  struct __gconv_step *__steps;
  __extension__ struct __gconv_step_data __data __flexarr;
} *__gconv_t;

and _G_config.h has

typedef union
{
  struct __gconv_info __cd;
  struct
  {
    struct __gconv_info __cd;
    struct __gconv_step_data __data;
  } __combined;
} _G_iconv_t;

where the inner struct has struct __gconv_info (which ends with a flexible 
array member) followed by another struct.

Reply via email to