This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/57175] NRVO and alignment
- From: "ebotcazou at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 05 May 2013 18:34:47 +0000
- Subject: [Bug c++/57175] NRVO and alignment
- Auto-submitted: auto-generated
- References: <bug-57175-4 at http dot gcc dot gnu dot org/bugzilla/>
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;