Hi! When a field has reference type, we correctly used the reference type as the type of the var with value expr, but the DECL_VALUE_EXPR had the type/value after convert_from_reference, which leads to invalid IL.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-12-29 Jakub Jelinek <ja...@redhat.com> PR c++/78931 * decl.c (cp_finish_decomp): SET_DECL_VALUE_EXPR to probe rather than tt. * g++.dg/cpp1z/decomp19.C: New test. --- gcc/cp/decl.c.jj 2016-12-21 22:57:08.000000000 +0100 +++ gcc/cp/decl.c 2016-12-28 13:16:45.294616666 +0100 @@ -7598,7 +7598,7 @@ cp_finish_decomp (tree decl, tree first, probe = TREE_OPERAND (probe, 0); TREE_TYPE (v[i]) = TREE_TYPE (probe); layout_decl (v[i], 0); - SET_DECL_VALUE_EXPR (v[i], tt); + SET_DECL_VALUE_EXPR (v[i], probe); DECL_HAS_VALUE_EXPR_P (v[i]) = 1; i++; } --- gcc/testsuite/g++.dg/cpp1z/decomp19.C.jj 2016-12-28 13:18:27.093305954 +0100 +++ gcc/testsuite/g++.dg/cpp1z/decomp19.C 2016-12-28 13:18:19.000000000 +0100 @@ -0,0 +1,13 @@ +// PR c++/78931 +// { dg-do run { target c++11 } } +// { dg-options "" } + +int +main () +{ + int x = 99; + struct S { int &x; }; + S s{x}; + auto [p] = s; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } } + return p - 99; +} Jakub