https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122958

            Bug ID: 122958
           Summary: [13/14/15/16 Regression] internal compiler error: tree
                    check: accessed elt 3 of 'tree_vec' with 2 elts in
                    tsubst, at cp/pt.cc:16806
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

template<typename A, typename B> struct Value { static constexpr bool value =
false; };
template<bool> struct Type { using type = void; };

template <class>
class Signal;

template <class RetT, class... Args>
class Signal<RetT(Args...)>;

template <
    class RetT,
    class... Args,
    class RetTC = typename Type<Value<RetT, void>::value>::type>
class Signal<RetT(Args...)>
{
};

Signal<void()> priv_signal_modified_changed2;


Using GCC 4.7.2 correctly rejects this:

<source>:14:7: error: default template arguments may not be used in partial
specializations
<source>:14:7: error: template parameters not used in partial specialization:
<source>:14:7: error:         'RetTC'
<source>:18:16: error: aggregate 'Signal<void()> priv_signal_modified_changed2'
has incomplete type and cannot be defined
Compiler returned: 1


GCC 4.7.[34] compiled this successfully! (accepts-invalid)

GCC 4.8.0 and later gives an ICE.

With trunk it says:

pr122958.cc: In instantiation of 'class Signal<void()>':
required from here
pr122958.cc:18:16:   
   18 | Signal<void()> priv_signal_modified_changed2;
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pr122958.cc:15:1: internal compiler error: tree check: accessed elt 3 of
'tree_vec' with 2 elts in tsubst, at cp/pt.cc:16806
   15 | {
      | ^
0x2514f4d internal_error(char const*, ...)
        /home/jwakely/src/gcc/gcc/gcc/diagnostic-global-context.cc:787
0x626dc8 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
        /home/jwakely/src/gcc/gcc/gcc/tree.cc:9390
0x794d5c tree_vec_elt_check(tree_node*, int, char const*, int, char const*)
        /home/jwakely/src/gcc/gcc/gcc/tree.h:3999
0x9c3062 tsubst(tree_node*, tree_node*, int, tree_node*)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.cc:16806
0x9c8e59 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.cc:14383
0x9c203d tsubst(tree_node*, tree_node*, int, tree_node*)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.cc:17025
0x9b4803 tsubst_decl
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.cc:15888
0x9c1d82 tsubst(tree_node*, tree_node*, int, tree_node*)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.cc:16608
0x9e39ef instantiate_class_template(tree_node*)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.cc:12882
0xa40ce4 complete_type(tree_node*)
        /home/jwakely/src/gcc/gcc/gcc/cp/typeck.cc:138
0x7e2878 start_decl_1(tree_node*, bool)
        /home/jwakely/src/gcc/gcc/gcc/cp/decl.cc:6776
0x7e2878 start_decl_1(tree_node*, bool)
        /home/jwakely/src/gcc/gcc/gcc/cp/decl.cc:6755
0x804551 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        /home/jwakely/src/gcc/gcc/gcc/cp/decl.cc:6742
0x9698ba cp_parser_init_declarator
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.cc:24895
0x96c72f cp_parser_simple_declaration
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.cc:17195
0x979878 cp_parser_declaration
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.cc:16815
0x97adab cp_parser_toplevel_declaration
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.cc:16836
0x97adab cp_parser_translation_unit
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.cc:5506
0x97adab c_parse_file()
        /home/jwakely/src/gcc/gcc/gcc/cp/parser.cc:55266
0xaea641 c_common_parse_file()
        /home/jwakely/src/gcc/gcc/gcc/c-family/c-opts.cc:1418
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to