https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70781
Bug ID: 70781 Summary: ICE on invalid C++ code with lambda expressions on x86_64-linux-gnu in finish_expr_stmt, at cp/semantics.c:677 Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu Target Milestone: --- The following code causes an ICE when compiled with the current GCC trunk on x86_64-linux-gnu in both 32-bit and 64-bit modes. It is a regression from 5.3.x. $ g++-trunk -v Using built-in specs. COLLECT_GCC=g++-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk --disable-bootstrap Thread model: posix gcc version 7.0.0 20160424 (experimental) [trunk revision 235394] (GCC) $ $ g++-5.3 -c small.cpp -std=c++11 small.cpp: In function ‘void foo()’: small.cpp:5:5: error: expected primary-expression before ‘(’ token T ([=] (S) { [=] {}; }); ^ small.cpp:5:11: error: ‘S’ has not been declared T ([=] (S) { [=] {}; }); ^ $ g++-trunk -c small.cpp -std=c++11 small.cpp: In lambda function: small.cpp:5:22: internal compiler error: in finish_expr_stmt, at cp/semantics.c:677 T ([=] (S) { [=] {}; }); ^ 0x7b4c50 finish_expr_stmt(tree_node*) ../../gcc-source-trunk/gcc/cp/semantics.c:677 0x745722 cp_parser_expression_statement ../../gcc-source-trunk/gcc/cp/parser.c:10720 0x73343b cp_parser_statement ../../gcc-source-trunk/gcc/cp/parser.c:10534 0x7340ec cp_parser_statement_seq_opt ../../gcc-source-trunk/gcc/cp/parser.c:10806 0x734bde cp_parser_lambda_body ../../gcc-source-trunk/gcc/cp/parser.c:10272 0x734bde cp_parser_lambda_expression ../../gcc-source-trunk/gcc/cp/parser.c:9756 0x735d8c cp_parser_primary_expression ../../gcc-source-trunk/gcc/cp/parser.c:4933 0x737e16 cp_parser_postfix_expression ../../gcc-source-trunk/gcc/cp/parser.c:6690 0x740f3c cp_parser_unary_expression ../../gcc-source-trunk/gcc/cp/parser.c:7988 0x741797 cp_parser_cast_expression ../../gcc-source-trunk/gcc/cp/parser.c:8665 0x741d95 cp_parser_binary_expression ../../gcc-source-trunk/gcc/cp/parser.c:8767 0x742680 cp_parser_assignment_expression ../../gcc-source-trunk/gcc/cp/parser.c:9055 0x7441c6 cp_parser_parenthesized_expression_list ../../gcc-source-trunk/gcc/cp/parser.c:7459 0x744c31 cp_parser_functional_cast ../../gcc-source-trunk/gcc/cp/parser.c:25943 0x737d0a cp_parser_postfix_expression ../../gcc-source-trunk/gcc/cp/parser.c:6615 0x740f3c cp_parser_unary_expression ../../gcc-source-trunk/gcc/cp/parser.c:7988 0x741797 cp_parser_cast_expression ../../gcc-source-trunk/gcc/cp/parser.c:8665 0x741d95 cp_parser_binary_expression ../../gcc-source-trunk/gcc/cp/parser.c:8767 0x742680 cp_parser_assignment_expression ../../gcc-source-trunk/gcc/cp/parser.c:9055 0x744f59 cp_parser_expression ../../gcc-source-trunk/gcc/cp/parser.c:9222 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. $ --------------------------------------------- template < typename T > // OK: template < typename T, typename S > void foo () { T ([=] (S) { [=] {}; }); }