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 via email to