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

--- Comment #2 from qinzhao at gcc dot gnu.org ---
(In reply to Cristian Rodríguez from comment #1)
> Any hope of getting this fixed for 15? it is quite annoying when trying to
> update older codebases to use c99 FAM.

a slightly modified source code will enable the -Wstrict-flex-arrays to report
the warning:

[opc@qinzhao-ol8u3-x86 111775]$ diff t.c t.c.org
18c18
<   printf("%p", f->fn.b[0]);
---
>   printf("%p", f->fn.b);

And with the following slightly modified testing case:

#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>

struct foo {
  int dum;
  char a[0];
};

int main(void)
{
  struct foo *f = malloc(sizeof(*f));
  /* or really any use of the union does not matter */
  printf("%p", f->a);
  free(f);
  return 0;
}

-Wstrict-flex-arrays does not report the warning either. 
so, this is not relating to union. It's relating to the reference to the array. 
in your testing case, the reference f->fn.b didn't imply that this will be used
as an flexible array, so, -Wstrict-flex-arrays has no reason to report any
warning for this.

So, I don't think this is a bug.

Reply via email to