https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87900
Bug ID: 87900 Summary: malloc + memse to calloc doesn't work for aggregate initialization Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- struct S { int a[1024]; }; struct S *foo () { struct S *p = (struct S *)__builtin_malloc (sizeof (struct S)); *p = (struct S){}; return p; } is not transformed to calloc, it only works when doing __builtin_memset (p, 0, sizeof (struct S)); the strlen pass is doing this transform (also DSEing zero-inits after calloc).