<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61121>61121</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
overload resolution issue when using user-defined conversion operator to const rvalue reference
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
namniav
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/4nrqj7n3o
```cpp
constexpr int f(int&&) { return 1; }
constexpr int f(const int&&) { return 2; }
struct A {
constexpr operator const int&&() const {
return static_cast<const int&&>(ref);
}
const int&& ref;
};
constexpr int i{42};
constexpr A a{static_cast<const int&&>(i)};
// Implicit conversion to function argument
// Clang: error: no viable conversion from 'A' to 'int'
// GCC & MSVC: OK
static_assert(f(a) == 2);
// Explicit call: OK
static_assert(f(a.operator const int&&()) == 2);
// Implicit call: OK
const int&& ref = a;
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVF2P2yoQ_TXjF7QRHhKTPPghH5urq6urPlTqa4XxJGFFwAWc3fbXVzibz91tV0I2GuacORwGVIxm64hqmCxgsipUn3Y-1E7tnVGHovHtz3qXUhdBzAHXgOutbxtv08iHLeD6F-B67MKPJ-mEB74CPoeKH4fuumNEexcTvXSBGZfYBnBqXAKshjFjIBcsUOqDYyWIBQO5-gg3RNhHaLxBH78xhV4nNs95xwhjF17fUVDJB_aGeJq5j9EL8rVOTCoZ_V2rmEAs76HiEXAaaAM4A3GueZbF7muxnHtKzGnn-TsmGJCLMV5nXdbnTIFcfEKcydLeFDoeL_t331mjTcoyDxSi8Y4lzza90ynPVdj2e3LpBrS0ym1BzBmF4EOeOM8ORjWWrnk2we8ZoJwDykwKKAdp8obsn-WSZV_-__ptmam-_Hc6ymFnKkYKCXCaG0INLSBWIFYMrx2_YXx8Oe1JWftXytGfu-JTFS8u3lV85_AzG1MXntP9KdpatDMxUwXVZSWlrKSsJsWu5oLLdlpJIVSJM9TTcUV8LNuqmjQTPuOFqZGj4IJjORYVn4yUUE1baqW5biuhWxhz2itjR9Ye9vkqFybGnuqqLLEsrGrIxuFJQHT0zIZFQMwvRKgz5qHptxHG3JqY4oUlmWSp9gcK1quWBYre9kPbDBTseUeO9dG4LesjhYeWNsZRe90jZ_OTf_U_HJTtKTtFgZymog_2_lEyadc3I-33gOus5vX30AX_RDoBrgcBEXA97PF3AAAA__-aOHqu">