https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105202
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I don't know. https://eel.is/c++draft/dcl.fct.def.default#1.1 says that defaulted comparison operator function doesn't have to be a special member function, but then https://eel.is/c++draft/class.compare.default#1 says that "A defaulted comparison operator function ([over.binary]) for some class C" ... but enums aren't classes... The reason for the ICE is that the https://wg21.link/p2085 implementation doesn't take the enums into account. --- gcc/cp/method.cc.jj 2022-04-02 12:48:32.000000000 +0200 +++ gcc/cp/method.cc 2022-04-08 13:51:00.588337683 +0200 @@ -1205,7 +1205,7 @@ early_check_defaulted_comparison (tree f for (; parmnode != void_list_node; parmnode = TREE_CHAIN (parmnode)) { tree parmtype = TREE_VALUE (parmnode); - if (CLASS_TYPE_P (parmtype)) + if (OVERLOAD_TYPE_P (parmtype)) saw_byval = true; else if (TREE_CODE (parmtype) == REFERENCE_TYPE && !TYPE_REF_IS_RVALUE (parmtype) @@ -1224,7 +1224,8 @@ early_check_defaulted_comparison (tree f if (!is_friend (ctx, fn)) error_at (loc, "defaulted %qD is not a friend of %qT", fn, ctx); } - else if (!same_type_ignoring_top_level_qualifiers_p (parmtype, ctx)) + else if (ctx + && !same_type_ignoring_top_level_qualifiers_p (parmtype, ctx)) saw_bad = true; } would avoid the ICE, but then it is rejected that it isn't a friend, which https://eel.is/c++draft/class.compare.default#1.2 requires (for classes) if it isn't a member function.