https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106644
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 53770 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53770&action=edit gcc13-pr106644-wip.patch Untested WIP. Compared to vanilla trunk, this rejects the f2 case which is a2 from the example in the standard. But doesn't handle anything else unfortunately. In the g1 case (c1 from the example in the standard), it is accepted for a wrong reason, decls_match rejects the comparison between B::operator== and C::operator!= because they have different CP_DECL_CONTEXT and so we think that the operator== is a rewrite target when it is not. Shall we use something different than decls_match (say a copy of it that ignores the context and for non-static members the this type too)? The reason it is then accepted is some non-standard handling of the rewritten/reversed candidates in joust? Then g2 case (c2 in the standard) is then incorrectly accepted because of that code in joust or so. Not really sure if we have a way to search just in a single namespace and not all the containing ones, and not sure about the using decls if those are something that should be ignored like in the patch or handled too. The k case in the testcase is I think because of joust too. The u3 case in the testcase is I think about whether using decls count or not. Anyway, the remaining // ERR cases are where clang++ trunk rejects stuff but we with the patch don't.