From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28755 invoked by alias); 22 Sep 2013 19:07:49 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 28727 invoked by uid 48); 22 Sep 2013 19:07:46 -0000 From: "reichelt at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/58503] New: ICE with invalid range in range-based for-loop Date: Sun, 22 Sep 2013 19:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: reichelt at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-09/txt/msg01615.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58503 Bug ID: 58503 Summary: ICE with invalid range in range-based for-loop Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: reichelt at gcc dot gnu.org The following invalid code snippet (compiled with "-std=c++0x") triggers an ICE since GCC 4.7.0: =================================== template void foo() { for (auto i : 0) {} } =================================== bug.cc: In function 'void foo()': bug.cc:3:17: error: there are no arguments to 'begin' that depend on a template parameter, so a declaration of 'begin' must be available [-fpermissive] for (auto i : 0) {} ^ bug.cc:3:17: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) bug.cc:3:17: error: there are no arguments to 'end' that depend on a template parameter, so a declaration of 'end' must be available [-fpermissive] bug.cc:3:17: internal compiler error: Segmentation fault 0xae93df crash_signal ../../gcc/gcc/toplev.c:335 0xcd77b0 strip_array_types(tree_node*) ../../gcc/gcc/tree.c:7815 0x65eba8 cp_type_quals(tree_node const*) ../../gcc/gcc/cp/typeck.c:8745 0x6cb5e4 cv_unqualified(tree_node*) ../../gcc/gcc/cp/tree.c:1144 0x62c8d0 cp_parser_perform_range_for_lookup ../../gcc/gcc/cp/parser.c:10176 0x6369c4 do_range_for_auto_deduction ../../gcc/gcc/cp/parser.c:9962 0x6369c4 cp_parser_range_for ../../gcc/gcc/cp/parser.c:9915 0x6369c4 cp_parser_for ../../gcc/gcc/cp/parser.c:9848 0x6369c4 cp_parser_iteration_statement ../../gcc/gcc/cp/parser.c:10295 0x6369c4 cp_parser_statement ../../gcc/gcc/cp/parser.c:9175 0x636dfe cp_parser_statement_seq_opt ../../gcc/gcc/cp/parser.c:9552 0x636f46 cp_parser_compound_statement ../../gcc/gcc/cp/parser.c:9506 0x648343 cp_parser_function_body ../../gcc/gcc/cp/parser.c:18313 0x648343 cp_parser_ctor_initializer_opt_and_function_body ../../gcc/gcc/cp/parser.c:18349 0x64937f cp_parser_function_definition_after_declarator ../../gcc/gcc/cp/parser.c:22333 0x64a099 cp_parser_function_definition_from_specifiers_and_declarator ../../gcc/gcc/cp/parser.c:22254 0x64a099 cp_parser_init_declarator ../../gcc/gcc/cp/parser.c:16348 0x64a994 cp_parser_single_declaration ../../gcc/gcc/cp/parser.c:22647 0x64d560 cp_parser_template_declaration_after_export ../../gcc/gcc/cp/parser.c:22449 0x655301 cp_parser_declaration ../../gcc/gcc/cp/parser.c:10728 Please submit a full bug report, [etc.] When the "-fpermissive" option is added, there is no error (only warnings) before the ICE. The code is wrongly accepted by GCC 4.6.x.