http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57485
Bug ID: 57485 Summary: memcpy in aggregate return not eliminated Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: mattiase at acm dot org Returning a big aggregate sometimes yields an avoidable temporary and memcpy. In this example, gcc manages to pass a pointer to the destination variable as the hidden struct return pointer only when that variable is being initialised, not when assigned separately. Observed in 4.8.0 for x86-64 and i686. struct S { int a[100]; }; struct S f(void); void g(struct S *p); void h(void) { #if 0 struct S s = f(); // no local temporary #else struct S s; s = f(); // local temporary and memcpy #endif g(&s); }