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

            Bug ID: 123401
           Summary: ICE: tree check: expected decl_minimal, have
                    view_convert_expr in dump_decl at cp/error.cc when
                    instantiating friend operator==<>
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Keywords: error-recovery, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 522024330006 at smail dot nju.edu.cn
  Target Milestone: ---

It is reproducible only in trunk.
Reproducer: https://godbolt.org/z/f9MYWxhW9

GCC crashes with a tree check failure (Internal Compiler Error) when
instantiating a class template containing a friend declaration of an operator
template with empty template arguments `<>`.

Program:
```c
template <typename T>
class B {
    friend bool operator==<>(B const &, B const &);
};

bool operator==(B<int> const &, B<int> const &) { 
    return true; 
}

int main() {
    B<int> b; 
}
```

Traceback:
```
tree check: expected tree that contains 'decl minimal' structure, have
'view_convert_expr' in dump_decl, at cp/error.cc:1619
    3 |     friend bool operator==<>(B const &, B const &);
      |                 ^~~~~~~~~~~~
0x29186f8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x290d4bb internal_error(char const*, ...)
        ???:0
0xa1832c tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
        ???:0
0x2979fe3 pretty_printer::format(text_info&)
        ???:0
0x2917ff3
diagnostics::context::report_diagnostic(diagnostics::diagnostic_info*)
        ???:0
0x29186f8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x290c339 error(char const*, ...)
        ???:0
0xdbd66c instantiate_class_template(tree_node*)
        ???:0
0xbe85c2 start_decl_1(tree_node*, bool)
        ???:0
0xc0cf41 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        ???:0
0xd53a33 c_parse_file()
        ???:0
0xec5469 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.
```

Reply via email to