This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/57230] [4.7/4.8/4.9 Regression] tree-ssa-strlen incorrectly optimizes a strlen to 0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57230

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
We have just one strlen pass instance, and even if we optimize the first strlen
there, having strlen pass duplicate constant propagation functionality just to
handle this weird testcase (storing strlen sizes inside of characters is
nothing common) doesn't make sense.
We could handle
int
main ()
{
  char p[] = "foobar";
  p[1] = 'O';
  p[6] = 'R';
  int len = strlen (p);
  foo (len);
}

perhaps, but it could work only for constant recorded string lengths, so that
the offset can be checked against that length, and would require known non-zero
value to be stored (or, once VRP info is preserved, perhaps just use the VRP
info to prove non-zero).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]