https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93266
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Keywords| |missed-optimization Last reconfirmed| |2020-01-14 CC| |msebor at gcc dot gnu.org Blocks| |83819 See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=81433, | |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=81704 Ever confirmed|0 |1 Severity|normal |enhancement --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- Into memset (b, 0, N) sounds right, for any empty source string, as in: void f (char *b, const char *a, unsigned n) { if (__builtin_strlen (a)) return; __builtin_strncpy (b, a, n); } Unfortunately, determining that a is empty in the strncpy call above is defeated by the super-early strlen() != 0 folding, so the strlen pass has no idea of a's length. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83819 [Bug 83819] [meta-bug] missing strlen optimizations