https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71570
Bug ID: 71570 Summary: ICE on invalid C++11 code (with invalid variable capture) on x86_64-linux-gnu: in cxx_incomplete_type_diagnostic, at cp/typeck2.c:551 Product: gcc Version: 7.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 C++11 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 also affects 6.1.x and is a regression from 5.4.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 20160617 (experimental) [trunk revision 237557] (GCC) $ $ g++-trunk -c small.cpp small.cpp: In function ‘void foo()’: small.cpp:5:5: error: cannot capture ‘foo’ by reference [&foo] ^~~ small.cpp: In lambda function: small.cpp:7:11: internal compiler error: in cxx_incomplete_type_diagnostic, at cp/typeck2.c:551 foo (0); ^ 0x727e2d cxx_incomplete_type_diagnostic(unsigned int, tree_node const*, tree_node const*, diagnostic_t) ../../gcc-source-trunk/gcc/cp/typeck2.c:551 0x7bffd5 cxx_incomplete_type_diagnostic ../../gcc-source-trunk/gcc/cp/cp-tree.h:6757 0x7bffd5 complete_type_or_maybe_complain(tree_node*, tree_node*, int) ../../gcc-source-trunk/gcc/cp/typeck.c:152 0x7cde76 decay_conversion(tree_node*, int, bool) ../../gcc-source-trunk/gcc/cp/typeck.c:2044 0x661e52 build_addr_func(tree_node*, int) ../../gcc-source-trunk/gcc/cp/call.c:282 0x7d0f6e cp_build_function_call_vec(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ../../gcc-source-trunk/gcc/cp/typeck.c:3583 0x817680 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int) ../../gcc-source-trunk/gcc/cp/semantics.c:2454 0x78ee50 cp_parser_postfix_expression ../../gcc-source-trunk/gcc/cp/parser.c:6904 0x78d4ac cp_parser_unary_expression ../../gcc-source-trunk/gcc/cp/parser.c:7986 0x797327 cp_parser_cast_expression ../../gcc-source-trunk/gcc/cp/parser.c:8663 0x797925 cp_parser_binary_expression ../../gcc-source-trunk/gcc/cp/parser.c:8765 0x798210 cp_parser_assignment_expression ../../gcc-source-trunk/gcc/cp/parser.c:9053 0x79ab09 cp_parser_expression ../../gcc-source-trunk/gcc/cp/parser.c:9220 0x79b12f cp_parser_expression_statement ../../gcc-source-trunk/gcc/cp/parser.c:10681 0x7a9f6b cp_parser_statement ../../gcc-source-trunk/gcc/cp/parser.c:10532 0x7aac2c cp_parser_statement_seq_opt ../../gcc-source-trunk/gcc/cp/parser.c:10804 0x7b03be cp_parser_lambda_body ../../gcc-source-trunk/gcc/cp/parser.c:10270 0x7b03be cp_parser_lambda_expression ../../gcc-source-trunk/gcc/cp/parser.c:9754 0x7848dc cp_parser_primary_expression ../../gcc-source-trunk/gcc/cp/parser.c:4934 0x78f076 cp_parser_postfix_expression ../../gcc-source-trunk/gcc/cp/parser.c:6691 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. $ ------------------------- void foo (int); void foo (void) { [&foo] { foo (0); }; }