https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70540
Bug ID: 70540 Summary: ICE on invalid code on x86_64-linux-gnu in cxx_incomplete_type_diagnostic, at cp/typeck2.c:569 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/6.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 6.0.0 20160404 (experimental) [trunk revision 234712] (GCC) $ $ g++-5.3 -c small.cpp small.cpp: In function ‘void foo()’: small.cpp:4:8: error: ‘f’ does not name a type auto f = [&] { return f; }; ^ $ $ g++-trunk -c small.cpp small.cpp: In lambda function: small.cpp:4:25: error: use of ‘f’ before deduction of ‘auto’ auto f = [&] { return f; }; ^ small.cpp:4:25: error: use of ‘foo()::<lambda()>::<f capture>’ before deduction of ‘auto’ small.cpp:4:28: internal compiler error: in cxx_incomplete_type_diagnostic, at cp/typeck2.c:569 auto f = [&] { return f; }; ^ 0x6ce8e3 cxx_incomplete_type_diagnostic(tree_node const*, tree_node const*, diagnostic_t) ../../gcc-source-trunk/gcc/cp/typeck2.c:569 0x765f99 complete_type_or_maybe_complain(tree_node*, tree_node*, int) ../../gcc-source-trunk/gcc/cp/typeck.c:150 0x7c37fc apply_deduced_return_type(tree_node*, tree_node*) ../../gcc-source-trunk/gcc/cp/semantics.c:9226 0x7342a2 cp_parser_lambda_body ../../gcc-source-trunk/gcc/cp/parser.c:10256 0x7342a2 cp_parser_lambda_expression ../../gcc-source-trunk/gcc/cp/parser.c:9756 0x734c9c cp_parser_primary_expression ../../gcc-source-trunk/gcc/cp/parser.c:4933 0x736d26 cp_parser_postfix_expression ../../gcc-source-trunk/gcc/cp/parser.c:6690 0x73fe6c cp_parser_unary_expression ../../gcc-source-trunk/gcc/cp/parser.c:7988 0x7406c7 cp_parser_cast_expression ../../gcc-source-trunk/gcc/cp/parser.c:8665 0x740cc5 cp_parser_binary_expression ../../gcc-source-trunk/gcc/cp/parser.c:8767 0x7415b0 cp_parser_assignment_expression ../../gcc-source-trunk/gcc/cp/parser.c:9055 0x7419ea cp_parser_constant_expression ../../gcc-source-trunk/gcc/cp/parser.c:9323 0x742174 cp_parser_initializer_clause ../../gcc-source-trunk/gcc/cp/parser.c:20793 0x74391b cp_parser_initializer ../../gcc-source-trunk/gcc/cp/parser.c:20734 0x752bce cp_parser_init_declarator ../../gcc-source-trunk/gcc/cp/parser.c:18604 0x7532b0 cp_parser_simple_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12379 0x7535c1 cp_parser_block_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12248 0x754018 cp_parser_declaration_statement ../../gcc-source-trunk/gcc/cp/parser.c:11860 0x7326db cp_parser_statement ../../gcc-source-trunk/gcc/cp/parser.c:10528 0x732ffc cp_parser_statement_seq_opt ../../gcc-source-trunk/gcc/cp/parser.c:10806 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 () { auto f = [&] { return f; }; }