[Bug tree-optimization/82911] missing strlen optimization for strncpy with constant strings and constant bound
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Sep 5 05:45:14 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82911
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2021-09-05
Status|UNCONFIRMED |NEW
Severity|normal |enhancement
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
A related testcase is:
void f1 (char *d, char *e, bool b)
{
d[2] = 0;
if (__builtin_strlen (d) > 2) // not eliminated but could be
__builtin_abort ();
}
where the strlen's range should be [0,2]. Maybe we can add a class to the
ranger for string and do the optimization that way instead.
so the null store to d[2] the range for the string becomes [0,2].
More information about the Gcc-bugs
mailing list