https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61969
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Andi Kleen from comment #6) > I looked at this a bit more. It's definitely the nrv pass that causes the > problem. > > When I disable it in the source code the 32bit version compiles correctly. > I also tried disabling the next pass (cfgcleanup), but that didn't make a > difference. > > It converts the local variable to be a value-expr. > > It's still not exactly clear who deletes the variable declaration though. > > There are two possibilities: > - nrv shouldn't convert the variable in the first place > - someone who messes with the variables forgets to check for value-exprs. > > ;; Function func_52 (func_52, funcdef_no=86, decl_uid=2858, cgraph_uid=54, > symbol_order=1152) > > NRV Replaced: l_55 with: <retval> > func_52 (uint32_t p_53) > { > extern const struct S0 l_55 = {.f0=4, .f1=40290, .f2=10, .f3=4} > [value-expr: <retval>]; only automatic vars may have a VALUE_EXPR, certainly not 'extern const' stuff. What does func_52 look like before the NRV pass? It must be sth like <retval> = l_55; ? Looks like a bug in nrv to me: /* The returned value must be a local automatic variable of the same type and alignment as the function's result. */ if (TREE_CODE (found) != VAR_DECL || TREE_THIS_VOLATILE (found) || DECL_CONTEXT (found) != current_function_decl || TREE_STATIC (found) || TREE_ADDRESSABLE (found) || DECL_ALIGN (found) > DECL_ALIGN (result) || !useless_type_conversion_p (result_type, TREE_TYPE (found))) return 0; should probably use auto_var_in_fn_p which checks for !DECL_EXTERNAL as well. Index: gcc/tree-nrv.c =================================================================== --- gcc/tree-nrv.c (revision 215917) +++ gcc/tree-nrv.c (working copy) @@ -216,8 +216,7 @@ pass_nrv::execute (function *fun) same type and alignment as the function's result. */ if (TREE_CODE (found) != VAR_DECL || TREE_THIS_VOLATILE (found) - || DECL_CONTEXT (found) != current_function_decl - || TREE_STATIC (found) + || !auto_var_in_fn_p (found, current_function_decl) || TREE_ADDRESSABLE (found) || DECL_ALIGN (found) > DECL_ALIGN (result) || !useless_type_conversion_p (result_type, > <bb 2>: > return <retval>; > > }