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: "mpolacek 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 14:06:36 +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 #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I've thought more like:
int
main ()
{
char p[] = "foobar";
int len = strlen (p);
p[1] = 'O';
p[6] = 'R';
int len2 = strlen (p);
foo (len, len2);
}
thus, there shouldn't be a need for the second strlen call, but currently we
generate it.
I'm looking into it today, but wasn't very successful so far, when we're
walking over handle_char_store statements, I don't know how to get the cached
string length of p. I wanted to use
idx = get_addr_stridx (lhs);
but that didn't work out.