Hi! When the prototype of defaulted comparison operator is incorrect, we set DECL_MAYBE_DELETED, but don't set DECL_DEFAULTED_FN and other flags, so we ICE during synthetize_method.
Seems only marking DECL_MAYBE_DELETED those operators that we are also going to mark DECL_DEFAULTED_FN results in better error recovery. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-12-17 Jakub Jelinek <ja...@redhat.com> PR c++/92966 * method.c (early_check_defaulted_comparison): Don't set DECL_MAYBE_DELETED when returning false. * g++.dg/cpp2a/spaceship-eq8.C: New test. --- gcc/cp/method.c.jj 2019-12-11 18:19:03.185162579 +0100 +++ gcc/cp/method.c 2019-12-17 15:28:57.819285145 +0100 @@ -1146,7 +1146,7 @@ early_check_defaulted_comparison (tree f } /* We still need to deduce deleted/constexpr/noexcept and maybe return. */ - DECL_MAYBE_DELETED (fn) = true; + DECL_MAYBE_DELETED (fn) = ok; return ok; } --- gcc/testsuite/g++.dg/cpp2a/spaceship-eq8.C.jj 2019-12-17 15:46:35.390322157 +0100 +++ gcc/testsuite/g++.dg/cpp2a/spaceship-eq8.C 2019-12-17 15:46:31.493380971 +0100 @@ -0,0 +1,8 @@ +// PR c++/92966 +// { dg-do compile { target c++2a } } + +struct S { + int operator==(const S&) const = default; // { dg-error "must return 'bool'" } + int s; // { dg-message "declared here" "" { target *-*-* } .-1 } +}; +static_assert(S{} == S{}); // { dg-error "" } Jakub