https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71604
Bug ID: 71604 Summary: ICE on valid C++11 code with range-based for loop: in pop_binding, at cp/name-lookup.c:376 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 causes 6.1.x to ICE, 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 20160620 (experimental) [trunk revision 237606] (GCC) $ $ g++-5.4 -c -std=c++11 small.cpp $ $ g++-trunk -c -std=c++11 small.cpp small.cpp: In function ‘void foo()’: small.cpp:5:5: internal compiler error: in pop_binding, at cp/name-lookup.c:376 ; ^ 0x86b26d pop_binding(tree_node*, tree_node*) ../../gcc-source-trunk/gcc/cp/name-lookup.c:376 0x6adf57 poplevel(int, int, int) ../../gcc-source-trunk/gcc/cp/decl.c:756 0x80e0e3 do_poplevel(tree_node*) ../../gcc-source-trunk/gcc/cp/semantics.c:446 0x81156b finish_for_stmt(tree_node*) ../../gcc-source-trunk/gcc/cp/semantics.c:1039 0x7b3d87 cp_parser_iteration_statement ../../gcc-source-trunk/gcc/cp/parser.c:11632 0x7a9a28 cp_parser_statement ../../gcc-source-trunk/gcc/cp/parser.c:10393 0x7aac6c cp_parser_statement_seq_opt ../../gcc-source-trunk/gcc/cp/parser.c:10804 0x7aad5f cp_parser_compound_statement ../../gcc-source-trunk/gcc/cp/parser.c:10758 0x7aaf0f cp_parser_function_body ../../gcc-source-trunk/gcc/cp/parser.c:20696 0x7aaf0f cp_parser_ctor_initializer_opt_and_function_body ../../gcc-source-trunk/gcc/cp/parser.c:20732 0x7ab9b1 cp_parser_function_definition_after_declarator ../../gcc-source-trunk/gcc/cp/parser.c:25415 0x7ac6c5 cp_parser_function_definition_from_specifiers_and_declarator ../../gcc-source-trunk/gcc/cp/parser.c:25327 0x7ac6c5 cp_parser_init_declarator ../../gcc-source-trunk/gcc/cp/parser.c:18468 0x7aca19 cp_parser_simple_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12378 0x7acd21 cp_parser_block_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12246 0x7b6100 cp_parser_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12143 0x7b4bd4 cp_parser_declaration_seq_opt ../../gcc-source-trunk/gcc/cp/parser.c:12022 0x7b4f08 cp_parser_translation_unit ../../gcc-source-trunk/gcc/cp/parser.c:4324 0x7b4f08 c_parse_file() ../../gcc-source-trunk/gcc/cp/parser.c:37486 0x918e52 c_common_parse_file() ../../gcc-source-trunk/gcc/c-family/c-opts.c:1070 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 a[2] = { 1, 2 }; for (struct S { S (int) {} } S : a) ; }