https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92774
Bug ID: 92774 Summary: ICE with defaulted three-way comparison function Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- #include <compare> template<typename T> struct X { }; template<typename T> bool operator==(const X<T>&, const X<T>&) { return true; } template<typename T> bool operator<(const X<T>&, const X<T>&) { return true; } struct Y { int a; X<int> c; auto operator <=>(Y const&) const = default; }; void f() { auto x = Y() < Y(); } This gets an ICE when compiled with -std=gnu++2a: ice.cc: In member function 'constexpr auto Y::operator<=>(const Y&) const': ice.cc:16:8: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in is_cat, at cp/method.c:999 16 | auto operator <=>(Y const&) const = default; | ^~~~~~~~ 0x7e1d30 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) /home/jwakely/src/gcc/gcc/gcc/tree.c:9738 0x618612 tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) /home/jwakely/src/gcc/gcc/gcc/tree.h:3396 0x618612 is_cat /home/jwakely/src/gcc/gcc/gcc/cp/method.c:999 0x9a226c cat_tag_for /home/jwakely/src/gcc/gcc/gcc/cp/method.c:1011 0x9a226c common_comparison_type /home/jwakely/src/gcc/gcc/gcc/cp/method.c:1166 0x9a226c build_comparison_op /home/jwakely/src/gcc/gcc/gcc/cp/method.c:1341 0x9a8809 synthesize_method(tree_node*) /home/jwakely/src/gcc/gcc/gcc/cp/method.c:1501 0x9637c7 mark_used(tree_node*, int) /home/jwakely/src/gcc/gcc/gcc/cp/decl2.c:5481 0x8c8611 build_over_call /home/jwakely/src/gcc/gcc/gcc/cp/call.c:8956 0x8cfc58 build_new_op_1 /home/jwakely/src/gcc/gcc/gcc/cp/call.c:6234 0x8d023d build_new_op(op_location_t const&, tree_code, int, tree_node*, tree_node*, tree_node*, tree_node**, int) /home/jwakely/src/gcc/gcc/gcc/cp/call.c:6499 0xa9b533 build_x_binary_op(op_location_t const&, tree_code, tree_node*, tree_code, tree_node*, tree_code, tree_node**, int) /home/jwakely/src/gcc/gcc/gcc/cp/typeck.c:4229 0x9cc6e1 cp_parser_binary_expression /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:9645 0x9cd557 cp_parser_assignment_expression /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:9780 0x9ccf3d cp_parser_constant_expression /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:10074 0x9cd501 cp_parser_initializer_clause /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:23023 0x9d16a7 cp_parser_initializer /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:22961 0x9fa521 cp_parser_init_declarator /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:20669 0x9da932 cp_parser_simple_declaration /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:13624 0x9dc669 cp_parser_declaration_statement /home/jwakely/src/gcc/gcc/gcc/cp/parser.c:13055 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.