[Bug c++/71662] New: ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71662] New: ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

abensonca at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662

            Bug ID: 71662
           Summary: ICE on invalid C++11 code with unqualified name look
                    up: in tsubst_copy, at cp/pt.c:14010
           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 affects older versions at least as early as 4.6.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 20160625 (experimental) [trunk revision 237780] (GCC)
$
$ g++-trunk -c -std=c++11 small.cpp
small.cpp: In instantiation of ‘A<T>::E A<T>::h() [with T = int]’:
small.cpp:8:23:   required from here
small.cpp:14:10: internal compiler error: in tsubst_copy, at cp/pt.c:14010
   return e;
          ^
0x6dfcdc tsubst_copy
        ../../gcc-source-trunk/gcc/cp/pt.c:14010
0x6e2906 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:17243
0x6d68ff tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15868
0x6d6f75 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15176
0x6d7e30 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15351
0x6d4835 instantiate_decl(tree_node*, int, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:22095
0x721512 instantiate_pending_templates(int)
        ../../gcc-source-trunk/gcc/cp/pt.c:22214
0x764645 c_parse_final_cleanups()
        ../../gcc-source-trunk/gcc/cp/decl2.c:4600
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.
$


----------------------------------------------------------


template < typename T > struct A
{
  enum E : T;
  E h ();
};

A < int > a;
A < int >::E b = a.h ();

template < typename T > enum A < T >::E : T { e };

template < typename T > typename A < T >::E A < T >::h ()
{
  return e;
}
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71662] [4.9/5/6/7 Regression] ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

abensonca at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-06-27
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org
   Target Milestone|---                         |4.9.4
            Summary|ICE on invalid C++11 code   |[4.9/5/6/7 Regression] ICE
                   |with unqualified name look  |on invalid C++11 code with
                   |up: in tsubst_copy, at      |unqualified name look up:
                   |cp/pt.c:14010               |in tsubst_copy, at
                   |                            |cp/pt.c:14010
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r165935.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71662] [4.9/5/6/7 Regression] ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

abensonca at gmail dot com
In reply to this post by abensonca at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71662] [4.9/5/6/7 Regression][DR 1485] ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

abensonca at gmail dot com
In reply to this post by abensonca at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.9/5/6/7 Regression] ICE  |[4.9/5/6/7 Regression][DR
                   |on invalid C++11 code with  |1485] ICE on invalid C++11
                   |unqualified name look up:   |code with unqualified name
                   |in tsubst_copy, at          |look up: in tsubst_copy, at
                   |cp/pt.c:14010               |cp/pt.c:14010

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Related to http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1485
which is still in drafting.  Discussion at the October 2012 meeting suggested
that an unscoped opaque enum declaration should be ill-formed.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71662] [4.9/5/6/7 Regression][DR 1485] ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

abensonca at gmail dot com
In reply to this post by abensonca at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.9.4                       |5.5

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 4.9 branch is being closed
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71662] [5/6/7/8 Regression][DR 1485] ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

abensonca at gmail dot com
In reply to this post by abensonca at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.5                         |6.5

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 5 branch is being closed
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71662] [6/7/8 Regression][DR 1485] ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

abensonca at gmail dot com
In reply to this post by abensonca at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo.carlini at oracle dot com

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This seems fixed in trunk, we simply reject the code without ICEing. While
reviewing this bug I noticed once more the nit that -Wreturn-type enabled by
default means that in such cases we emit a redundant warning:

71662.C:14:10: error: ‘e’ was not declared in this scope
   return e;
          ^
71662.C: In instantiation of ‘A<T>::E A<T>::h() [with T = int]’:
71662.C:8:23:   required from here
71662.C:15:1: warning: no return statement in function returning non-void
[-Wreturn-type]

but that seems an unrelated issue, really. Thus I mean to commit the testcase
and remove the 8 Regression marker.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71662] [6/7/8 Regression][DR 1485] ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

abensonca at gmail dot com
In reply to this post by abensonca at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662

--- Comment #6 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Wed Feb  7 09:35:10 2018
New Revision: 257439

URL: https://gcc.gnu.org/viewcvs?rev=257439&root=gcc&view=rev
Log:
2018-02-07  Paolo Carlini  <[hidden email]>

        PR c++/71662
        * g++.dg/cpp0x/scoped_enum7.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/scoped_enum7.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71662] [6/7 Regression][DR 1485] ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

abensonca at gmail dot com
In reply to this post by abensonca at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.5                         |7.4

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 6 branch is being closed
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71662] [7 Regression][DR 1485] ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

abensonca at gmail dot com
In reply to this post by abensonca at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.4                         |7.5
Reply | Threaded
Open this post in threaded view
|

[Bug c++/71662] [7 Regression][DR 1485] ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010

abensonca at gmail dot com
In reply to this post by abensonca at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to work|                            |8.0
         Resolution|---                         |FIXED
   Target Milestone|7.5                         |8.0
      Known to fail|                            |7.5.0

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC8.