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

            Bug ID: 120289
           Summary: internal compiler error: tree check: accessed elt 2 of
                    'tree_vec' with 1 elts in tsubst, at cp/pt.cc:16650
                    since 6.1
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mario.rodriguezb1 at um dot es
  Target Milestone: ---

Code thats produce ICE:

```
#include <iostream>
template <class T, class Allocator = std::allocator<T>>
class std::allocator{}
```

Stack dump

```
/opt/compiler-explorer/gcc-trunk-20250515/include/c++/16.0.0/bits/allocator.h:183:9:
internal compiler error: tree check: accessed elt 2 of 'tree_vec' with 1 elts
in tsubst, at cp/pt.cc:16650
  183 |         allocator(const allocator<_Tp1>&) _GLIBCXX_NOTHROW { }
      |         ^~~~~~~~~
0x2943505 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x2961276 internal_error(char const*, ...)
        ???:0
0x9e3b59 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
        ???:0
0xb57966 tree_vec_elt_check(tree_node*, int, char const*, int, char const*)
        ???:0
0xd35054 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xd48ee9 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xd33f01 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xd5156d instantiate_template(tree_node*, tree_node*, int)
        ???:0
0xd510b3 instantiate_template(tree_node*, tree_node*, int)
        ???:0
0xd5cc8a fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
        ???:0
0xaf94bb build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ???:0
0xc36acf implicitly_declare_fn(special_function_kind, tree_node*, bool,
tree_node*, tree_node*)
        ???:0
0xc37a75 lazily_declare_fn(special_function_kind, tree_node*)
        ???:0
0xc7d611 get_class_binding(tree_node*, tree_node*, bool)
        ???:0
0xd6ec98 lookup_member(tree_node*, tree_node*, int, bool, int,
access_failure_info*)
        ???:0
0xd6f244 lookup_fnfields(tree_node*, tree_node*, int, int)
        ???:0
0xafab7d build_special_member_call(tree_node*, tree_node*, vec<tree_node*,
va_gc, vl_embed>**, tree_node*, int, int)
        ???:0
0xc07b5a build_aggr_init(tree_node*, tree_node*, int, int)
        ???:0
0xc0cec4 emit_mem_initializers(tree_node*)
        ???:0
0xd2772d instantiate_decl(tree_node*, bool, bool)
        ???:0
```

To quickly reproduce:

In no asserted versions, bailing out is shown instead of ICE

https://godbolt.org/z/j5hPbWjEn

Reply via email to