[Bug c++/101889] New: [11/12 Regression] ICE with template argument deduction of broken template

reichelt at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Aug 12 18:08:42 GMT 2021


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

            Bug ID: 101889
           Summary: [11/12 Regression] ICE with template argument
                    deduction of broken template
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: error-recovery, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reichelt at gcc dot gnu.org
  Target Milestone: ---

The following invalid code snippet triggers an ICE since GCC 11:

==============================
template<int> struct A {};

template<T> struct B
{
  enum { E = 0 };
  B(A<E>) {}
};

B b = A<0>();
==============================

bug.cc:3:10: error: 'T' has not been declared
    3 | template<T> struct B
      |          ^
bug.cc:9:12: internal compiler error: tree check: expected enumeral_type, have
error_mark in tsubst_copy, at cp/pt.c:16588
    9 | B b = A<0>();
      |            ^
0x85a540 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/gcc/tree.c:8686
0x6e74ea tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/gcc/tree.h:3373
0x6e74ea tsubst_copy
        ../../gcc/gcc/cp/pt.c:16588
0xaf1eb4 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:20870
0xafd357 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:19092
0xb12264 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:13355
0xb1b763 tsubst_aggr_type
        ../../gcc/gcc/cp/pt.c:13559
0xb1be34 tsubst_arg_types
        ../../gcc/gcc/cp/pt.c:14958
0xb1ed5a tsubst_arg_types
        ../../gcc/gcc/cp/pt.c:14935
0xb1ed5a build_deduction_guide
        ../../gcc/gcc/cp/pt.c:28776
0xaec0b6 ctor_deduction_guides_for
        ../../gcc/gcc/cp/pt.c:29184
0xaec0b6 deduction_guides_for
        ../../gcc/gcc/cp/pt.c:29257
0xaec576 do_class_deduction
        ../../gcc/gcc/cp/pt.c:29378
0xaec576 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
        ../../gcc/gcc/cp/pt.c:29535
0x9d9608 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../gcc/gcc/cp/decl.c:7856
0xac5174 cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.c:22556
0xaa0773 cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.c:15088
0xacfdb5 cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:14787
0xad078e cp_parser_toplevel_declaration
        ../../gcc/gcc/cp/parser.c:14808
0xad078e cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:4978
Please submit a full bug report, [etc.]


More information about the Gcc-bugs mailing list