https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102724
Bug ID: 102724 Summary: [11/12 Regression] ICE in genericize_spaceship, at cp/method.c:1089 Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: error-recovery, ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: asolokha at gmx dot com Target Milestone: --- g++-12.0.0-alpha20211010 snapshot (g:74ccca380cde5e79e082d39214b306a90ded0344) ICEs when compiling the following testcase, reduced from test/CXX/class/class.compare/class.spaceship/p1.cpp from the clang 12.0.0 test suite, w/ -std=c++20: namespace std { struct strong_ordering { int n; constexpr operator int() const { return n; } static const strong_ordering less, equal, greater; }; constexpr strong_ordering strong_ordering::less{-1}, strong_ordering::equal{0}, strong_ordering::greater{1}; } namespace Synthesis { enum Result { False, True, Mu }; constexpr bool toBool(Result R) { return R == True; } struct Val { Result equal, less; constexpr bool operator==(const Val&) const { return toBool(equal); } constexpr bool operator<(const Val&) const { return toBool(less); } }; template<typename T> struct Cmp { Val val; friend T operator<=>(const Cmp&, const Cmp&) = default; }; struct custom_ordering { custom_ordering(std::strong_ordering o); }; void f(Cmp<custom_ordering> c) { c <=> c; } } % g++-12.0.0 -std=c++20 -c mfri5bsa.cpp mfri5bsa.cpp: In function 'void Synthesis::f(Synthesis::Cmp<Synthesis::custom_ordering>)': mfri5bsa.cpp:31:11: error: use of deleted function 'constexpr Synthesis::custom_ordering Synthesis::operator<=>(const Synthesis::Cmp<Synthesis::custom_ordering>&, const Synthesis::Cmp<Synthesis::custom_ordering>&)' 31 | c <=> c; | ^ mfri5bsa.cpp:24:14: note: 'constexpr Synthesis::custom_ordering Synthesis::operator<=>(const Synthesis::Cmp<Synthesis::custom_ordering>&, const Synthesis::Cmp<Synthesis::custom_ordering>&)' is implicitly deleted because the default definition would be ill-formed: 24 | friend T operator<=>(const Cmp&, const Cmp&) = default; | ^~~~~~~~ mfri5bsa.cpp:23:9: error: no match for 'operator<=>' (operand types are 'Synthesis::Val' and 'Synthesis::Val') 23 | Val val; | ^~~ mfri5bsa.cpp:24:14: internal compiler error: in genericize_spaceship, at cp/method.c:1089 24 | friend T operator<=>(const Cmp&, const Cmp&) = default; | ^~~~~~~~ 0x6ba1ae genericize_spaceship(unsigned int, tree_node*, tree_node*, tree_node*) /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/method.c:1089 0xa3d849 do_one_comp /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/method.c:1388 0xa3e2de build_comparison_op(tree_node*, bool, int) /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/method.c:1595 0xa45d4e maybe_explain_implicit_delete(tree_node*) /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/method.c:2822 0x9f7d7c mark_used(tree_node*, int) /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/decl2.c:5703 0x93e0a6 build_over_call /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/call.c:9721 0x9449f2 build_new_op_1 /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/call.c:6711 0x9450cd build_new_op(op_location_t const&, tree_code, int, tree_node*, tree_node*, tree_node*, tree_node**, int) /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/call.c:6970 0xb939cd build_x_binary_op(op_location_t const&, tree_code, tree_node*, tree_code, tree_node*, tree_code, tree_node**, int) /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/typeck.c:4483 0xaa3ec7 cp_parser_binary_expression /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/parser.c:10073 0xaa469d cp_parser_assignment_expression /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/parser.c:10211 0xaa6162 cp_parser_expression /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/parser.c:10381 0xaa99f8 cp_parser_expression_statement /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/parser.c:12574 0xab6ff9 cp_parser_statement /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/parser.c:12370 0xab80bd cp_parser_statement_seq_opt /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/parser.c:12722 0xab8198 cp_parser_compound_statement /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/parser.c:12671 0xad9138 cp_parser_function_body /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/parser.c:24904 0xad9138 cp_parser_ctor_initializer_opt_and_function_body /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/parser.c:24955 0xad9eba cp_parser_function_definition_after_declarator /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/parser.c:31085 0xadb22b cp_parser_function_definition_from_specifiers_and_declarator /var/tmp/portage/sys-devel/gcc-12.0.0_alpha20211010/work/gcc-12-20211010/gcc/cp/parser.c:31001