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

            Bug ID: 89744
           Summary: [8/9 Regression] ICE with specialization of nested
                    template class
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-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 valid testcase triggers an ICE since GCC 8.1.0:

========================================
template<typename> struct A
{
  template<typename> struct B {};
  A() { B<int> b; }
};

template<> template<typename>
struct A<int>::B
{
  virtual void foo() {}
};

A<int> a;
========================================

bug.cc: In instantiation of 'struct A<int>::B<int>':
bug.cc:10:16:   recursively required from 'void A<int>::B<
<template-parameter-1-1> >::foo() [with <template-parameter-1-1> = int]'
bug.cc:10:16:   required from here
bug.cc:9:1: internal compiler error: in finish_member_declaration, at
cp/semantics.c:3126
    9 | {
      | ^
0x68321f finish_member_declaration(tree_node*)
        ../../gcc/gcc/cp/semantics.c:3126
0xa3175f instantiate_class_template_1
        ../../gcc/gcc/cp/pt.c:11167
0xa3175f instantiate_class_template(tree_node*)
        ../../gcc/gcc/cp/pt.c:11468
0xa7750d complete_type(tree_node*)
        ../../gcc/gcc/cp/typeck.c:138
0xa3f0af lookup_member(tree_node*, tree_node*, int, bool, int,
access_failure_info*)
        ../../gcc/gcc/cp/search.c:1129
0x994575 get_class_binding
        ../../gcc/gcc/cp/name-lookup.c:4451
0x9991bf outer_binding(tree_node*, cxx_binding*, bool)
        ../../gcc/gcc/cp/name-lookup.c:6330
0x9a07d4 check_local_shadow
        ../../gcc/gcc/cp/name-lookup.c:2631
0x9a07d4 do_pushdecl
        ../../gcc/gcc/cp/name-lookup.c:3097
0x9a07d4 pushdecl(tree_node*, bool)
        ../../gcc/gcc/cp/name-lookup.c:3162
0x928dfe store_parm_decls
        ../../gcc/gcc/cp/decl.c:15683
0x928dfe start_preparsed_function(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/decl.c:15555
0xa2fb66 instantiate_decl(tree_node*, bool, bool)
        ../../gcc/gcc/cp/pt.c:24643
0xa33c8b instantiate_pending_templates(int)
        ../../gcc/gcc/cp/pt.c:24777
0x952258 c_parse_final_cleanups()
        ../../gcc/gcc/cp/decl2.c:4802
Please submit a full bug report, [etc.]


However, similar testcases regressed with different releases.
ICE since GCC 4.0.0:

========================================
template<typename> struct A
{
  template<typename> struct B {};
  A() { B<int> b; }
};

template<> template<typename>
struct A<int>::B
{
  virtual void foo() {}
  void bar() {}
};

A<int> a;
========================================

ICE since GCC 3.2.3:

========================================
template<typename> struct A
{
  template<typename> struct B {};
  A() { B<int> b; }
};

template<> template<typename>
struct A<int>::B
{
  ~B() {}
};

A<int> a;
========================================

ICE since GCC 4.8.4:

========================================
template<typename...> struct A
{
  template<typename> struct B {};
  typedef B<int> X;
};

template<> template<typename>
struct A<int>::B
{
  typedef int Y;
};

A<int>::B<int> b;
========================================

Reply via email to