https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57485
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Status|UNCONFIRMED |NEW Last reconfirmed| |2017-06-01 CC| |msebor at gcc dot gnu.org Ever confirmed|0 |1 Known to fail| |4.8.3, 4.9.3, 5.3.0, 6.2.0, | |7.1.0 --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- Confirmed with 7.1 with the following test case. The assembly shows the memcpy (expanded inline). $ cat t.c && gcc -O2 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout t.c struct S { int a[100]; }; struct S f (void); void g(struct S *p); void h (void) { struct S s = f(); // no local temporary g(&s); } void j (void) { struct S s; s = f(); // local temporary and memcpy g(&s); } ;; Function h (h, funcdef_no=0, decl_uid=1799, cgraph_uid=0, symbol_order=0) h () { struct S s; <bb 2> [100.00%]: s = f (); [return slot optimization] g (&s); s ={v} {CLOBBER}; return; } ;; Function j (j, funcdef_no=1, decl_uid=1803, cgraph_uid=1, symbol_order=1) j () { struct S s; <bb 2> [100.00%]: s = f (); g (&s); s ={v} {CLOBBER}; return; }