https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93266
Bug ID: 93266 Summary: strlen pass could optimize strncpy with known strlen (src) == 0 into memset Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- In: char b[32]; void foo () { char a[16]; __builtin_memcpy (a, "\0foobarbazquuxy", 16); __builtin_strncpy (b, a, 32); } we could turn the strncpy into memset (b, ' ', 32);