<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJylVE1vozAQ_TXmMmpEIIRw4ECS7p5WqpTV3v0xBDcEI9u0an_9jiENaVVVlWoZe8Ye_J7fDAijXkq2ji893rO4ct4O0sMDsHw7rbAk1TUsJweoeTz3LffI0p1suXNwYOn9vC2MacH0aLk3lqX70JONNJ3zcACWrFlSwOiydIbA1uG3IWqrsVNfIj1MSDt4D_wOslO6vnj5ft651aECllbQD6LV8iLKTeglaPtl0DSOXGWD8kQUK-CB2hZE0OKqdLiaRT_YDjhM96GI6zl05mS8z9g0_m0QaGlShgyoh056bTp4Nvbk4HEgFWrdYQAWgwdPL5zxLNDOoUqjg2ftm8-B0p0zg5UYcpFWyywMq3B1tDYkoILBIZgazBPa1nCF6poe0j9_S1EO2gE_C30czOBoZxMwp1BKq3_pMazmVQgNKzRvw_uUv28IBXNj-T2w7H40Pr1EoL-MA_XOhHKrQBKgVlR7syws244EDwELtizb_6jaZ3bZT0hdVLNIYjtSuueWn9FTPo1VaMfKeke8uhL_tIJ-73aj2H8O_8iQEntPt_PNAhrve0c0WPKL-tEoYVq_MPZI3is9RfNYZNmq7m6PY6tYPYuW65OmylzFry9H0xqtIFJlqoq04BEffGNsqeJTNNi2_ABDxAexkOZMTts-vU13vTWPKD252rkBHRlZWmSrqCnTtOYiq9drkaJaizzbFIoLhVwIIXORRy0X9KMpSReWJJIlNG2TmGySJvo5A10mcTL20JJ4sUGeLbO1KJa5lKtckQ545rpdhHOCgpEtxyPFcHS02Wrn3bxJfz597BBHwsTQa99iuXvj_aHubj6pMetUBPoJ1Z03d4LTh0lVGEqFiicaeZcj6f-O3747>53954</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            C++20 operator== ambiguous with derived-to-base conversion
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c++20
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          d0k
      </td>
    </tr>
</table>

<pre>
    ```
struct P {
#if 1
    template<class S>
    bool operator==(const S &) const;
#else
    template<class S>
    friend bool operator==(const P &, const S &);
#endif
};

struct A : public P {};
struct B : public P {};

bool check(A a, B b) {
    return a == b;
}
```

The `friend` function works just fine, but the member function dies with
```
<source>:15:14: error: use of overloaded operator '==' is ambiguous (with operand types 'A' and 'B')
    return a == b;
           ~ ^  ~
<source>:4:10: note: candidate function [with S = B]
    bool operator==(const S &) const;
         ^
<source>:4:10: note: candidate function (with reversed parameter order) [with S = A]
```

GCC and MSVC accept both. https://godbolt.org/z/9hj9554fn

@dwblaikie @zygoloid 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVMFuozAQ_RpzGTUiEEo5cCBJd08rVcpq78YeghsHI9u0ar9-x5CGpIqqSkXGzNhjvzdvRtRGvpXsPj6NeMviynk7CA9PwPL1tMKSVDWwnBygx-Ox19wjSzdCc-dgx9LHebs2RoPp0XJvLEu3YSQPwnTOww5Ycs-SAkaXpTMEaoffhmiswk5-ifQ0IW3gGvgKspOqOXn5dt651KECllbQD7VW4iTKRegpaP1l0DSPXEWL4kAUK-CB2hrqoMVZ6ZCaRT_YDjhM-VDE-R66czKuKzbNf1sEWpqUIQOaoRNemQ5ejT04eB5IhUZ1GIDrwYOnA0c81mjnUKnQwavy7W2gdOPMYAWGWqTVMgvTKqSO1oYCVDA4BNOAeUGrDZcoz-Uh_fOPEuWgHPBjrfaDGRztPATMKZTK6t96DKt5FULDCn3X4TzV7xtCwfyw_BFY9jgaN5MI9JdxoN6Z0G4VCAJUknpvloVl65HgLmDBmmXbH3X7zC77CamTahZJbEdK99zyI3qqp7ES7dhZV8SrM_GbHfR7sxnF_rP7R4YQ2HvKzrcLaL3vHdFgyS8aeyNro_3C2D157_QW7XORZaumu7yOrWL5WmuuDoo6cxW_v-2NNkpCJMtUFmnBI6-8xnLDEiruOok_yXjRIWMSlJN6QXnnzV3Nqc9I1JA5aRENVpefSNKJoV4IcyRH65ePz11vzTMKT65ybkBHRpYW2SpqyyLJRIZNmtY8Q8mLJE-w4AViLgrOMxlpXtNvqiRVWZKID9pkk7CRKpM4GUd4knjxgDxbZvd1scyFWOWSNMAjV3oReAT1IluOlOph72hTK-fdvEl_PbXvEEc4up8PvjW2lPEhGpmXI-3_5kioPg">