[Bug middle-end/71625] missing strlen optimization on different array initialization style

renlin at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jun 24 09:08:00 GMT 2016


--- Comment #9 from Renlin Li <renlin at gcc dot gnu.org> ---
(In reply to nsz from comment #8)
> (In reply to Jakub Jelinek from comment #6)
> > (In reply to Marc Glisse from comment #1)
> > > Or we could do like clang and improve alias analysis. We should know that
> > > array doesn't escape and thus that hallo() cannot write to it.
> > 
> > The strlen pass uses the alias oracle, so the question is why it thinks the
> > call might affect the array.
> the optimization fails with
>  const char array[] = "abc";
> too (which is why i thought it was about pure strlen depending on global
> state
> other than the argument.. static const array works though).

char *array = "abc";

works, however, this generates string literals in read-only section.

More information about the Gcc-bugs mailing list