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

            Bug ID: 120879
           Summary: ICE: tree check: expected tree_vec, have
                    identifier_node in tsubst_decl, at cp/pt.cc:15757
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: ice-checking, ice-on-invalid-code, needs-reduction
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rush102333 at gmail dot com
  Target Milestone: ---

$cat test.cpp
template<typename ...T> auto lambda1() {
  return [](auto x) { 
    struct A : T::template X<decltype(x)>... {
      using T::template X<decltype(x)>::f ...;
      using typename T::template X<decltype(x)>::type ...;
      void g(int n) { f(n); } 
      void h() { type value; }

A self_member; };
    return A();
  };
}

struct A {
template<typename> template<typename> struct X {
    void f(int);
    using type = int;
    X self_member; 
    };
};

void f() {
lambda1<A>()
    (0)
    .g(0);
}


With assertion enabled:
$g++ test.cpp
<source>: In lambda function:
<source>:9:3: error: field 'self_member' has incomplete type
'lambda1()::<lambda(auto:1)>::A' [-Wtemplate-body]
    9 | A self_member; };
      |   ^~~~~~~~~~~
<source>:3:12: note: definition of 'struct lambda1()::<lambda(auto:1)>::A' is
not complete until the closing brace
    3 |     struct A : T::template X<decltype(x)>... {
      |            ^
<source>: At global scope:
<source>:15:46: error: too many template-parameter-lists
   15 | template<typename> template<typename> struct X {
      |                                              ^
<source>: In instantiation of 'struct lambda1<A>()::<lambda(auto:1)>::A':
<source>:9:16:   required from 'lambda1<A>()::<lambda(auto:1)> [with auto:1 =
int]'
    9 | A self_member; };
      |                ^
<source>:24:5:   required from here
   23 | lambda1<A>()
      | ~~~~~~~~~~~~
   24 |     (0)
      |     ^~~
<source>:3:12: error: no class template named 'X' in 'struct A'
    3 |     struct A : T::template X<decltype(x)>... {
      |            ^
<source>:4:43: error: no class template named 'X' in 'struct A'
    4 |       using T::template X<decltype(x)>::f ...;
      |                                           ^~~
<source>:4:43: internal compiler error: tree check: expected tree_vec, have
identifier_node in tsubst_decl, at cp/pt.cc:15757
0x2844425 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x2866fc6 internal_error(char const*, ...)
        ???:0
0x9f8e25 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0xd4c0c4 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xd7a999 instantiate_class_template(tree_node*)
        ???:0
0xd6e87d instantiate_decl(tree_node*, bool, bool)
        ???:0
0xbf7843 maybe_instantiate_decl(tree_node*)
        ???:0
0xbf95b7 mark_used(tree_node*, int)
        ???:0
0xb2a403 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
        ???:0
0xd98c6e finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0xd166e3 c_parse_file()
        ???:0
0xe7e469 c_common_parse_file()
        ???:0
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.


Godbolt: https://godbolt.org/z/73s69KMd9

Reply via email to