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

            Bug ID: 96656
           Summary: Segmentation fault with make_friend_class
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tangyixuan at mail dot dlut.edu.cn
  Target Milestone: ---

Please consider the following code. Clang++ compiles it successfully, while g++
fails:

$: cat s.cpp

struct a{};
template <class A> struct b {
    using c=a;
};

class B {
    template <class X>
    friend class b<X>::c;
};

int main() {
    B b;
}

$: g++ -c s.cpp
s.cpp:8:25: internal compiler error: Segmentation fault
    8 |     friend class b<X>::c;
      |                         ^
0xc6a68f crash_signal
        ../../gcc-11-20200628/gcc/toplev.c:328
0x6d01b4 make_friend_class(tree_node*, tree_node*, bool)
        ../../gcc-11-20200628/gcc/cp/friend.c:400
0x73ef87 cp_parser_template_declaration_after_parameters
        ../../gcc-11-20200628/gcc/cp/parser.c:29140
0x73f0aa cp_parser_explicit_template_declaration
        ../../gcc-11-20200628/gcc/cp/parser.c:29388
0x718a29 cp_parser_member_specification_opt
        ../../gcc-11-20200628/gcc/cp/parser.c:24850
0x718a29 cp_parser_class_specifier_1
        ../../gcc-11-20200628/gcc/cp/parser.c:23947
0x71a603 cp_parser_class_specifier
        ../../gcc-11-20200628/gcc/cp/parser.c:24254
0x71a603 cp_parser_type_specifier
        ../../gcc-11-20200628/gcc/cp/parser.c:17762
0x71b422 cp_parser_decl_specifier_seq
        ../../gcc-11-20200628/gcc/cp/parser.c:14410
0x71bf41 cp_parser_simple_declaration
        ../../gcc-11-20200628/gcc/cp/parser.c:13664
0x741e16 cp_parser_declaration
        ../../gcc-11-20200628/gcc/cp/parser.c:13484
0x742504 cp_parser_translation_unit
        ../../gcc-11-20200628/gcc/cp/parser.c:4761
0x742504 c_parse_file()
        ../../gcc-11-20200628/gcc/cp/parser.c:44043
0x80bc8b c_common_parse_file()
        ../../gcc-11-20200628/gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to