We miscompile some perl testcases because int i; struct X { int *p; }; struct X * __attribute__((malloc)) my_alloc (void) { struct X *p = __builtin_malloc (sizeof (struct X)); p->p = &i; return p; } extern void abort (void); int main() { struct X *p, *q; p = my_alloc (); q = my_alloc (); *(p->p) = 1; *(q->p) = 0; if (*(p->p) != 0) abort (); return 0; }
we treat my_alloc like plain malloc, not possibly initializing the allocated storage. -- Summary: [4.5 Regression] Attribute malloc not handled correctly Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rguenth at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43008