https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103562
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Martin Liška from comment #1) > So there's fishy the [return slot optimization]. RSO should be fine there, that is what you get even with the C code version from GCC (-O2 -fno-inline): ;; Function deref (deref, funcdef_no=0, decl_uid=1982, cgraph_uid=1, symbol_order=0) struct my_struct deref (struct my_struct * ptr) { <bb 2> [local count: 1073741824]: <retval> = *ptr_2(D); return <retval>; } ;; Function get_a (get_a, funcdef_no=1, decl_uid=1985, cgraph_uid=2, symbol_order=1) long int get_a (struct my_struct * s) { struct my_struct D.1993; long int _4; <bb 2> [local count: 1073741824]: D.1993 = deref (s_2(D)); [return slot optimization] _4 = D.1993.a; return _4; }