https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86701
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=122754
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #6)
> (In reply to Jan Hubicka from comment #5)
> > I think this is a valid testcase showing that we can't optimize it:
> >
> > #include<string>
> > #include<cstdio>
> > #include<cstring>
> > int
> > main()
> > {
> > std::string str="";
> > str.push_back (0);
> > printf ("%i %i\n", str.length(), strlen (str.c_str()));
> > return 0;
> > }
>
> That is some other issue.
> The strlen pass should have figured that out:
> MEM <vector(2) char> [(char_type &)&str + 16] = { 0, 0 };
> _1 = strlen (&str.D.25443._M_local_buf);
>
> Reduced testcase for that:
Turns out that is pointers vs references, see PR 122754.
Otherwise this is invalid as mentioned std::string could in theory contain a
null char.