http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57175
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2013-05-05 CC| |ebotcazou at gcc dot | |gnu.org Ever Confirmed|0 |1 --- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2013-05-05 18:34:47 UTC --- > in typeck.c (check_return_expr), before applying the NRV optimization, there > is a check: DECL_ALIGN (retval) >= DECL_ALIGN (result) > > It seems to me that this check is backwards and should be <= instead (compare > with tree_nrv in tree-nrv.c which seems correct). FWIW the Ada compiler also has the NRVO and the check is as in tree-nrv.c: /* Return true if RET_VAL can be used as a Named Return Value for the anonymous return object RET_OBJ. */ static bool return_value_ok_for_nrv_p (tree ret_obj, tree ret_val) { [...] if (ret_obj && DECL_ALIGN (ret_val) > DECL_ALIGN (ret_obj)) return false;