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

--- Comment #1 from John David Anglin <danglin at gcc dot gnu.org> ---
Martin Sebor wrote on 2019-08-14:

I don't know about the flifetime-dse2.C test but the Warray-bounds-4.C warning
is the result of a recent enhancement to the strlen optimization, either
r274486 or r273783.  On the hppa2.0w-hp-hpux11.11 target the warning newly
added in r273783 sees the following code:

  main ()
  {
    const struct FixedString empty;

    <bb 2> [local count: 1073741824]:
    MEM[(int (*) () * *)&empty] = &MEM <int (*) ()[8]> [(void
*)&_ZTV11FixedStringILm0EE + 8B];
    MEM[(char *)&empty + 4B] = 0;
    print_length (&empty.D.2009);   <<<
    empty ={v} {CLOBBER};
    empty ={v} {CLOBBER};
    return 0;
  }

and diagnoses the invalid store at <<< before VRP gets to it and issues
-Warray-bounds.  On other targets like sparc-solaris2.11, the strlen pass sees
the following code:

main ()
{
  const struct FixedString empty;

  <bb 2> [local count: 1073741824]:
  MEM[(struct FixedString *)&empty] ={v} {CLOBBER};
  MEM[(struct FixedString *)&empty].D.2008._vptr.String = &MEM <int (*) ()[8]>
[(void *)&_ZTV11FixedStringILm0EE + 8B];
  MEM[(struct FixedString *)&empty].contents[0] = 0;   <<<
  print_length (&empty.D.2008);
  empty ={v} {CLOBBER};
  empty ={v} {CLOBBER};
  return 0;

}

and it doesn't handle this form of the assignment (it doesn't know how to
determine the size of the referenced object).  Ideally, both kinds would be
handled and the same warning would be issued.  It means enhancing the object
size detection (compute_objsize in builtins.c).

Reply via email to