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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Slightly simplified -O2 -Wall:
struct S {};
struct T { struct S s[3]; struct S t; };
void bar (struct S *);

void
foo (struct T *t)
{
  for (int i = 0; i < 3; i++)
    bar (&t->s[i]);
}
On:
void
baz (struct T *t)
{
  for (int i = 0; i < 4; i++)
    bar (&t->s[i]);
}
we on the other side don't warn iN GCC 12 even when we probably should:
fre3 in that case replaces:
  _10 = &t_5(D)->s[0];
  bar (_10);
  _15 = &t_5(D)->s[1];
  bar (_15);
  _20 = &t_5(D)->s[2];
  bar (_20);
  _25 = &t_5(D)->s[3];
  bar (_25);
with
  _10 = &t_5(D)->s[0];
  bar (_10);
  bar (_10);
  bar (_10);
  bar (_10);
and the warning is only in vrp1.
void
qux (struct T *t)
{
  bar (&t->s[2]);
}

void
corge (struct T *t)
{
  bar (&t->s[3]);
}
are then even simpler cases.  r13-4521 and later warns for all those, GCC 12
for none of those.

Reply via email to