public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58503] New: ICE with invalid range in range-based for-loop
@ 2013-09-22 19:07 reichelt at gcc dot gnu.org
  2013-10-03  9:26 ` [Bug c++/58503] [c++11] " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: reichelt at gcc dot gnu.org @ 2013-09-22 19:07 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/58503] [c++11] ICE with invalid range in range-based for-loop
  2013-09-22 19:07 [Bug c++/58503] New: ICE with invalid range in range-based for-loop reichelt at gcc dot gnu.org
@ 2013-10-03  9:26 ` paolo.carlini at oracle dot com
  2013-10-04 23:17 ` paolo at gcc dot gnu.org
  2013-10-04 23:18 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-03  9:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58503

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-10-03
   Target Milestone|---                         |4.9.0
     Ever confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Mine.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/58503] [c++11] ICE with invalid range in range-based for-loop
  2013-09-22 19:07 [Bug c++/58503] New: ICE with invalid range in range-based for-loop reichelt at gcc dot gnu.org
  2013-10-03  9:26 ` [Bug c++/58503] [c++11] " paolo.carlini at oracle dot com
@ 2013-10-04 23:17 ` paolo at gcc dot gnu.org
  2013-10-04 23:18 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo at gcc dot gnu.org @ 2013-10-04 23:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58503

--- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Fri Oct  4 23:17:51 2013
New Revision: 203219

URL: http://gcc.gnu.org/viewcvs?rev=203219&root=gcc&view=rev
Log:
/cp
2013-10-04  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/58503
    * parser.c (cp_parser_perform_range_for_lookup): If eventually
    either *begin or *end is type-dependent, return NULL_TREE.
    (do_range_for_auto_deduction): If cp_parser_perform_range_for_lookup
    returns NULL_TREE, don't actually do_auto_deduction.

/testsuite
2013-10-04  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/58503
    * g++.dg/cpp0x/range-for26.C: New.
    * g++.dg/cpp0x/range-for27.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/range-for26.C
    trunk/gcc/testsuite/g++.dg/cpp0x/range-for27.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/58503] [c++11] ICE with invalid range in range-based for-loop
  2013-09-22 19:07 [Bug c++/58503] New: ICE with invalid range in range-based for-loop reichelt at gcc dot gnu.org
  2013-10-03  9:26 ` [Bug c++/58503] [c++11] " paolo.carlini at oracle dot com
  2013-10-04 23:17 ` paolo at gcc dot gnu.org
@ 2013-10-04 23:18 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-04 23:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58503

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
           Assignee|paolo.carlini at oracle dot com    |unassigned at gcc dot gnu.org

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed for 4.9.0.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-04 23:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-22 19:07 [Bug c++/58503] New: ICE with invalid range in range-based for-loop reichelt at gcc dot gnu.org
2013-10-03  9:26 ` [Bug c++/58503] [c++11] " paolo.carlini at oracle dot com
2013-10-04 23:17 ` paolo at gcc dot gnu.org
2013-10-04 23:18 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).