This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/58503] New: ICE with invalid range in range-based for-loop
- From: "reichelt at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 22 Sep 2013 19:07:45 +0000
- Subject: [Bug c++/58503] New: ICE with invalid range in range-based for-loop
- Auto-submitted: auto-generated
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<int> 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.