https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85210

            Bug ID: 85210
           Summary: ICE with broken structured binding in template
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: error-recovery, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reichelt at gcc dot gnu.org
  Target Milestone: ---

The following invalid code snippet (compiled with "-std=c++1z") triggers
an ICE since GCC 7.1.0 (structured bindings were introduced):

============================
struct A { int i; };

template<int> void foo(int j)
{
  auto [j] = A{j};
}

void bar()
{
  foo<0>(0);
}
============================

bug.cc: In function 'void foo(int)':
bug.cc:5:10: error: declaration of 'auto j' shadows a parameter
   auto [j] = A{j};
          ^
bug.cc: In instantiation of 'void foo(int) [with int <anonymous> = 0]':
bug.cc:10:11:   required from here
bug.cc:5:8: internal compiler error: in fit_decomposition_lang_decl, at
cp/lex.c:724
   auto [j] = A{j};
        ^~~
0x61802a fit_decomposition_lang_decl(tree_node*, tree_node*)
        ../../gcc/gcc/cp/lex.c:724
0x8a2868 cp_finish_decomp(tree_node*, tree_node*, unsigned int)
        ../../gcc/gcc/cp/decl.c:7545
0x9746fd tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16409
0x96f15f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16561
0x96e2f8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16249
0x96e2f8 instantiate_decl(tree_node*, bool, bool)
        ../../gcc/gcc/cp/pt.c:23659
0x9932db instantiate_pending_templates(int)
        ../../gcc/gcc/cp/pt.c:23775
0x8b893b c_parse_final_cleanups()
        ../../gcc/gcc/cp/decl2.c:4724
Please submit a full bug report, [etc.]

Reply via email to