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

--- Comment #16 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning code hasn't changed.  What's different is that the MEM_REF that
-Warray-bounds doesn't handle isn't in the IL anymore.  The
hppa2.0w-hp-hpux11.11 IL for the test case in comment #6 looks just like the
x86_64 IL and so the same warning is issued for both (see below).  I don't know
what commit is behind the change.

$ cat pr91457.C && /build/hppa2.0w-hp-hpux11.11/gcc-svn/gcc/xgcc -B
/build/hppa2.0w-hp-hpux11.11/gcc-svn/gcc -S -O2 -Wall
-fdump-tree-dom3=/dev/stdout pr91457.C
struct A
{
  char n, a[0];

  A () { a[0] = 0; }
};

void f (struct A*);

void g (void)
{
  struct A a;
  f (&a);
}
pr91457.C: In function 'void g()':
pr91457.C:5:13: warning: array subscript 0 is above array bounds of 'char [0]'
[-Warray-bounds]
    5 |   A () { a[0] = 0; }
      |          ~~~^
pr91457.C:3:11: note: while referencing 'A::a'
    3 |   char n, a[0];
      |           ^

;; Function g (_Z1gv, funcdef_no=3, decl_uid=1937, cgraph_uid=4,
symbol_order=3)

;; 1 loops found
;;
;; Loop 0
;;  header 0, latch 1
;;  depth 0, outer -1
;;  nodes: 0 1 2
;; 2 succs { 1 }
g ()
{
  struct A a;

  <bb 2> [local count: 1073741824]:
  a ={v} {CLOBBER};
  a.a[0] = 0;
  f (&a);
  a ={v} {CLOBBER};
  return;

}

Reply via email to