This fixes PR60895 - copying TREE_ADDRESSABLE from a decl to a handled-component-ref doesn't work as the inliner tries to do. Use mark_addressable instead.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk and 4.9 branch. Richard. 2014-04-23 Richard Biener <rguent...@suse.de> PR middle-end/60895 * tree-inline.c (declare_return_variable): Use mark_addressable. * g++.dg/torture/pr60895.C: New testcase. Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 209559) +++ gcc/tree-inline.c (working copy) @@ -3120,7 +3124,8 @@ declare_return_variable (copy_body_data { var = return_slot; gcc_assert (TREE_CODE (var) != SSA_NAME); - TREE_ADDRESSABLE (var) |= TREE_ADDRESSABLE (result); + if (TREE_ADDRESSABLE (result)) + mark_addressable (var); } if ((TREE_CODE (TREE_TYPE (result)) == COMPLEX_TYPE || TREE_CODE (TREE_TYPE (result)) == VECTOR_TYPE) Index: gcc/testsuite/g++.dg/torture/pr60895.C =================================================================== --- gcc/testsuite/g++.dg/torture/pr60895.C (revision 0) +++ gcc/testsuite/g++.dg/torture/pr60895.C (working copy) @@ -0,0 +1,32 @@ +// { dg-do compile } + +struct C +{ + double elems[3]; +}; + +C +foo () +{ + C a; + double *f = a.elems; + int b; + for (; b;) + { + *f = 0; + ++f; + } + return a; +} + +struct J +{ + C c; + __attribute__((always_inline)) J () : c (foo ()) {} +}; + +void +bar () +{ + J (); +}