[Bug tree-optimization/87900] New: malloc + memse to calloc doesn't work for aggregate initialization

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Nov 6 11:35:00 GMT 2018


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).


More information about the Gcc-bugs mailing list