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

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Here's a small test case that causes a bogus false positive with patched GCC
(https://gcc.gnu.org/pipermail/gcc-patches/2020-November/558775.html).

$ cat t.C && gcc -O2 -S -Wall t.C
struct A  { char a[32]; };
struct B: virtual A { };
struct C: B { };

struct D 
{
  B &b;
  D (B&);
};

D::D (B &b): b (b) { }

void f (void*);

void g ()
{
  C c;
  D d (c);
  f (&d);
}
In constructor ‘D::D(B&)’,
    inlined from ‘void g()’ at t.C:18:9:
t.C:11:14: warning: subscript 0 is outside array bounds of ‘B’ [-Warray-bounds]
   11 | D::D (B &b): b (b) { }
      |              ^~~~~
t.C: In function ‘void g()’:
t.C:3:8: note: source object ‘C::<anonymous>’ of size 8
    3 | struct C: B { };
      |        ^

Reply via email to