Hi! When the structured binding decl doesn't have a reference type, cp_finish_decl makes sure its type is complete, but if it has a reference type, that doesn't happen and we ICE trying to access bases of a not yet instantiated type.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-11-30 Jakub Jelinek <ja...@redhat.com> PR c++/83217 * decl.c (cp_finish_decomp): If decl's type is REFERENCE_TYPE, call complete_type (TREE_TYPE (type)). * g++.dg/cpp1z/decomp33.C: New test. --- gcc/cp/decl.c.jj 2017-11-30 11:18:00.000000000 +0100 +++ gcc/cp/decl.c 2017-11-30 15:34:55.873673157 +0100 @@ -7424,7 +7424,9 @@ cp_finish_decomp (tree decl, tree first, if (TREE_CODE (type) == REFERENCE_TYPE) { dexp = convert_from_reference (dexp); - type = TREE_TYPE (type); + type = complete_type (TREE_TYPE (type)); + if (type == error_mark_node) + goto error_out; } tree eltype = NULL_TREE; --- gcc/testsuite/g++.dg/cpp1z/decomp33.C.jj 2017-11-30 15:37:58.781405774 +0100 +++ gcc/testsuite/g++.dg/cpp1z/decomp33.C 2017-11-30 15:38:28.006043496 +0100 @@ -0,0 +1,21 @@ +// PR c++/83217 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template <typename T> +struct S +{ + T a; +}; + +void +foo (S<int> *b) +{ + auto & [c] = *b; // { dg-warning "structured bindings only available with" "" { target c++14_down } } +} + +void +bar (S<char> *d) +{ + auto [e] = *d; // { dg-warning "structured bindings only available with" "" { target c++14_down } } +} Jakub