[Bug c++/72764] New: ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

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

[Bug c++/72764] New: ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

            Bug ID: 72764
           Summary: ICE on invalid C++11 code instantiating an alias
                    template: tree check: expected class ‘type’, have
                    ‘exceptional’ (error_mark) in typedef_variant_p, at
                    tree.c:12660
           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: ---

It affects 4.8.x and later, which ICE without any proper diagnostics. It is
correctly rejected by 4.7.x.

It is related to PR 72763, which is derived from the same original test.


$ 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 20160731 (experimental) [trunk revision 238915] (GCC)
$
$ g++-trunk -c -std=c++11 small.cpp
small.cpp:10:26: internal compiler error: tree check: expected class ‘type’,
have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660
   struct D : B < C < T > > {};
                          ^
0x1071227 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ../../gcc-source-trunk/gcc/tree.c:9793
0x10812d0 tree_class_check
        ../../gcc-source-trunk/gcc/tree.h:3402
0x10812d0 typedef_variant_p(tree_node const*)
        ../../gcc-source-trunk/gcc/tree.c:12660
0x852520 strip_typedefs(tree_node*, bool*)
        ../../gcc-source-trunk/gcc/cp/tree.c:1494
0x6bba03 canonicalize_type_argument
        ../../gcc-source-trunk/gcc/cp/pt.c:6979
0x6f31b6 convert_template_argument
        ../../gcc-source-trunk/gcc/cp/pt.c:7251
0x6feea3 coerce_template_parms
        ../../gcc-source-trunk/gcc/cp/pt.c:7746
0x700dda lookup_template_class_1
        ../../gcc-source-trunk/gcc/cp/pt.c:8319
0x700dda lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
        ../../gcc-source-trunk/gcc/cp/pt.c:8662
0x81e28d finish_template_type(tree_node*, tree_node*, int)
        ../../gcc-source-trunk/gcc/cp/semantics.c:3133
0x7aa444 cp_parser_template_id
        ../../gcc-source-trunk/gcc/cp/parser.c:14961
0x7aa6ea cp_parser_class_name
        ../../gcc-source-trunk/gcc/cp/parser.c:21265
0x79910d cp_parser_qualifying_entity
        ../../gcc-source-trunk/gcc/cp/parser.c:6271
0x79910d cp_parser_nested_name_specifier_opt
        ../../gcc-source-trunk/gcc/cp/parser.c:5955
0x791fd4 cp_parser_base_specifier
        ../../gcc-source-trunk/gcc/cp/parser.c:23046
0x791fd4 cp_parser_base_clause
        ../../gcc-source-trunk/gcc/cp/parser.c:22895
0x791fd4 cp_parser_class_head
        ../../gcc-source-trunk/gcc/cp/parser.c:22102
0x791fd4 cp_parser_class_specifier_1
        ../../gcc-source-trunk/gcc/cp/parser.c:21347
0x791fd4 cp_parser_class_specifier
        ../../gcc-source-trunk/gcc/cp/parser.c:21656
0x791fd4 cp_parser_type_specifier
        ../../gcc-source-trunk/gcc/cp/parser.c:15883
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 > struct A;
template < typename > struct B {};

template < typename T >
using C = typename A < T >::template D < T >;

template < typename T > struct A
{
  // should be: template < typename > struct D : B < C < T > > {};
  struct D : B < C < T > > {};
};

A < int > a;
Reply | Threaded
Open this post in threaded view
|

[Bug c++/72764] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-08-01
                 CC|                            |marxin at gcc dot gnu.org
   Target Milestone|---                         |4.9.4
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/72764] [4.9/5/6/7 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

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

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

--- Comment #2 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++/72764] [5/6/7 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
      Known to fail|                            |4.8.2, 4.9.3, 5.3.0, 6.1.0,
                   |                            |7.0

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
r191412 is the first commit that triggers the ICE:

r191412 | jason | 2012-09-17 23:47:35 -0400 (Mon, 17 Sep 2012) | 4 lines

        PR c++/54575
        * pt.c (instantiate_alias_template): New.
        (tsubst): Use it.
        (push_access_scope): Allow TYPE_DECL.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/72764] [5/6/7 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

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++/72764] [5/6/7 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Seems both make_typename_type and finish_decltype_type can return
error_mark_node even if the arguments passed to those aren't error_mark_node
(as they are called tf_none, no diagnostics is emitted).
The question is what strip_typedefs should do if that happens?  Shall it return
error_mark_node, or the original type, something different?  The end of the
function assumes that result is a valid type.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/72764] [5/6/7 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

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

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

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Mine.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/72764] [5/6/7 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Paolo, any progress with this?
The last mail on the subject is
http://gcc.gnu.org/ml/gcc-patches/2017-01/msg01813.html
Reply | Threaded
Open this post in threaded view
|

[Bug c++/72764] [5/6/7 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

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

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

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Hi Jakub. Sorry, no, no progress, I'm unassigning myself for the time being.
Reply | Threaded
Open this post in threaded view
|

[Bug c++/72764] [5/6/7/8 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
Reply | Threaded
Open this post in threaded view
|

[Bug c++/72764] [5/6/7/8 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Wed Jun 28 21:06:35 2017
New Revision: 249760

URL: https://gcc.gnu.org/viewcvs?rev=249760&root=gcc&view=rev
Log:
        PR c++/72764 - ICE with invalid template typename.

        * decl.c (build_typename_type): No longer static.
        * tree.c (strip_typedefs): Use it instead of make_typename_type.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/alias-decl-60.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/tree.c
Reply | Threaded
Open this post in threaded view
|

[Bug c++/72764] [5/6/7 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

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

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

--- Comment #9 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++/72764] [6/7 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

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

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

--- Comment #10 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++/72764] [7 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

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++/72764] [7 Regression] ICE on invalid C++11 code instantiating an alias template: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in typedef_variant_p, at tree.c:12660

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72764

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

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

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