<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/82509>82509</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang][Sema] Clang can't choose from a member and a non member operator
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    Consider the following code:

```
struct s{
    template<class T>
 int operator+(const T&)const{return 0;}
};

template<class T>
concept AlwaysTrue=true;

template<AlwaysTrue T>
int operator+(const s&,const T&){return 1;}

int main(){
    return s{}+1;
}
```
godbolt example: https://godbolt.org/z/vG31vjxbn
Since the 2nd `operator+` is more constrained clang should choose that. However clang reports an ambiguity. (GCC chooses the 2nd one as expected)   
Note that the ambiguity remains if the only 1st, or both declaration have a concept, (even if one of them is more constrained).
If we define both operators inside the class or both operators outside the class clang chooses the correct overload.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VMGO4ygQ_ZrypTQRxnFsH3yYJJuZuexl-gewqcSMMBUBTnfv16-MnU56tLNSFAQ8Xr33KKNCMBdH1EK5h_KYqSkO7NvvvOcfIetYv7cHdsFo8hgHwjNby6_GXbBnTVB8BXEEcf_fifWXpiH6qY8YoNovC4iIkcarVZGgOPRWhYAvUPy1bhsXka_kVWQPcg-y7tmFiC8gdyCbNIFq7ylO3qGAYg_VcS1dHefpk5j_KdSz6-ka8at9Ve_hxU8ExTGm4U8UD-gTz5_0hqT38En8Q3f-SfcH0aiMA1kv0Ede66EUYnUEuc8fIj9IPud-Yd2xjUhvarza-ZJwiPEa5tuSJ5CnFbBhfwF5-gfk6fatyG-_3jq3MPw0rqd039JphJ14drkTaAKO7AmTQ6-MI429Ve6CYeDJauwH5jAzqLjB7_xKN_IrwtOVfQyoHKqxM5fJxPcNgqy_HQ7rufBRmh2hCkhvV-ojaZANIi4a_-a4FEjgDyr0NCcZ0JzTBjv7jnmIIA_IHjuOA2rqrfIqGnY4qBuhwrUlZhTImm7kZoK5PCee8b88g2w2i5gfZ3wl1HQ2jpYa98QCmvT5JDFLI95lPCA8xd8wS1bPcfTsPfUR-UbestKbTLeFbopGZdTmlajLYidEkQ1tJ7uyK3VdNXUj610h8t02r6pC51t1PqsyM60UciukzPNKClFsRK5ksRX1WZSN6AqCrZhTtBtrb-PcJpkJYaK2lqVoMqs6siG9GFImoSDl_Hj4dsZ_6aZLgK2wJsTwYIgm2vTMHNKJ8gjl_ieNCsojHha3yoGs4r15zp5HVDjS2JFH5TQqdOzuC_f0ssnb9rf-NnGYuk3PI8jTLGAdvlw9_6I-gjwlPwHkKVn6NwAA__8uJJY9">