[Bug c++/95972] ICE in check_member_template, at cp/decl2.c:570

haoxintu at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Jul 3 03:14:23 GMT 2020


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

--- Comment #1 from Haoxin Tu <haoxintu at gmail dot com> ---
Hi, there.

I guess I shouldn't use C-Reduce to reduce my ICE on invalid code cases. After
using C-Reduce, the cases are more like a "garbage" code.

Here is a more readable code to reproduce the ICE.

$cat p.cc
int a() { 
    auto var = [] ( struct s{ int b( auto);} ){};
}

$g++ -w p.cc
p.cc: In function ‘int a()’:
p.cc:2:29: error: types may not be defined in parameter types
    2 |     auto var = [] ( struct s{ int b( auto);} ){};
      |                             ^
p.cc:2:42: internal compiler error: in check_member_template, at cp/decl2.c:570
    2 |     auto var = [] ( struct s{ int b( auto);} ){};
      |                                          ^
0x6890c4 check_member_template(tree_node*)
        ../../gcc/cp/decl2.c:570
0xa41c20 finish_member_template_decl(tree_node*)
        ../../gcc/cp/pt.c:308
0x9f86ba finish_fully_implicit_template
        ../../gcc/cp/parser.c:44279
0xa3a12a cp_parser_member_declaration
        ../../gcc/cp/parser.c:25414
0xa0e061 cp_parser_member_specification_opt
        ../../gcc/cp/parser.c:24850
0xa0e061 cp_parser_class_specifier_1
        ../../gcc/cp/parser.c:23947
0xa10213 cp_parser_class_specifier
        ../../gcc/cp/parser.c:24254
0xa10213 cp_parser_type_specifier
        ../../gcc/cp/parser.c:17762
0xa11172 cp_parser_decl_specifier_seq
        ../../gcc/cp/parser.c:14410
0xa2db8f cp_parser_parameter_declaration
        ../../gcc/cp/parser.c:22818
0xa2e582 cp_parser_parameter_declaration_list
        ../../gcc/cp/parser.c:22641
0xa2e95c cp_parser_parameter_declaration_clause
        ../../gcc/cp/parser.c:22568
0xa2f34e cp_parser_lambda_declarator_opt
        ../../gcc/cp/parser.c:11102
0xa16fb8 cp_parser_lambda_expression
        ../../gcc/cp/parser.c:10633
0xa16fb8 cp_parser_primary_expression
        ../../gcc/cp/parser.c:5443
0xa21110 cp_parser_postfix_expression
        ../../gcc/cp/parser.c:7296
0xa03d6a cp_parser_binary_expression
        ../../gcc/cp/parser.c:9609
0xa058ce cp_parser_assignment_expression
        ../../gcc/cp/parser.c:9914
0xa0468d cp_parser_constant_expression
        ../../gcc/cp/parser.c:10208
0xa04df1 cp_parser_initializer_clause
        ../../gcc/cp/parser.c:23272
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.

While in Clang
$clang++ -w p.cc
p.cc:2:28: error: 's' cannot be defined in a parameter type
    auto var = [] ( struct s{ int b( auto);} ){};
                           ^
1 error generated.

The ICE just cased by the struct used as a lambda expression parameter. And ICE
point out the parser can not deal with the "auto" keywords and then crashed on
it.


More information about the Gcc-bugs mailing list