This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/57230] [4.7/4.8/4.9 Regression] tree-ssa-strlen incorrectly optimizes a strlen to 0
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 10 May 2013 13:42:55 +0000
- Subject: [Bug tree-optimization/57230] [4.7/4.8/4.9 Regression] tree-ssa-strlen incorrectly optimizes a strlen to 0
- Auto-submitted: auto-generated
- References: <bug-57230-4 at http dot gcc dot gnu dot org/bugzilla/>
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).