https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71169
Bug ID: 71169 Summary: [7 Regression] ICE on invalid C++ code in pop_nested_class (cp/class.c:7785) Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org Target Milestone: --- Hi. Follow code was created during reduction of a different problem: $ cat invalid.cc template <Preconditioner> class A { template <class = int> m_fn1() { m_fn1() } } $ invalid.cc:1:11: error: ‘Preconditioner’ has not been declared template <Preconditioner> class A { ^~~~~~~~~~~~~~ invalid.cc:2:32: error: ISO C++ forbids declaration of ‘m_fn1’ with no type [-fpermissive] template <class = int> m_fn1() { ^ invalid.cc:5:1: error: expected ‘;’ after class definition } ^ invalid.cc: In substitution of ‘template<<typeprefixerror><anonymous> > template<class> int A<<anonymous> >::m_fn1() [with <template-parameter-2-1> = <missing>; <typeprefixerror><anonymous> = int]’: invalid.cc:3:9: required from here invalid.cc:3:9: internal compiler error: Segmentation fault m_fn1() ^ 0xd7d93f crash_signal ../../gcc/toplev.c:333 0x731f03 tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) ../../gcc/tree.h:3147 0x731f03 pop_nested_class() ../../gcc/cp/class.c:7785 0x6f6ede instantiate_template_1 ../../gcc/cp/pt.c:17400 0x6f6ede instantiate_template(tree_node*, tree_node*, int) ../../gcc/cp/pt.c:17449 0x7084d7 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node* const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool) ../../gcc/cp/pt.c:17808 0x66ddd0 add_template_candidate_real ../../gcc/cp/call.c:3110 0x66eb2c add_template_candidate ../../gcc/cp/call.c:3188 0x66eb2c add_candidates ../../gcc/cp/call.c:5361 0x66f3af build_new_method_call_1 ../../gcc/cp/call.c:8312 0x66f3af build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int) ../../gcc/cp/call.c:8511 0x784522 cp_parser_postfix_expression ../../gcc/cp/parser.c:6875 0x78205c cp_parser_unary_expression ../../gcc/cp/parser.c:7986 0x78c097 cp_parser_cast_expression ../../gcc/cp/parser.c:8663 0x78c65b cp_parser_binary_expression ../../gcc/cp/parser.c:8764 0x78cf20 cp_parser_assignment_expression ../../gcc/cp/parser.c:9051 0x78f84a cp_parser_expression ../../gcc/cp/parser.c:9220 0x78fdf3 cp_parser_expression_statement ../../gcc/cp/parser.c:10681 0x79f156 cp_parser_statement ../../gcc/cp/parser.c:10532 0x79fb3c cp_parser_statement_seq_opt ../../gcc/cp/parser.c:10804 GCC 6.1 works fine. Martin