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

    <tr>
        <th>Summary</th>
        <td>
            Clang behavior diverges in `T&` and `T const&` conversions when using explicit object parameter `this auto&&`.
        </td>
    </tr>

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

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

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

<pre>
    ```c++
#include <utility>

struct Foo {
    int& n;

    template <class T>
    operator decltype(std::declval<T&&>().n)(this T&& self) {
 return ((T&&)self).n;
    }
};

int x;
Foo y{x};

int a = y;
int& b = y;
int const& c = y;
```

[godbolt](https://godbolt.org/z/x9bdxvMGT)

```
<source>:16:6: error: non-const lvalue reference to type 'int' cannot bind to a value of unrelated type 'Foo'
   16 | int& b = y;
      |      ^ ~
```

Clang fails to convert `y` to `int&` but has no complaints about the `int` or `int const&` conversion. It feels like it's deducing the result as a plain `int`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VM-S-jYMfhpx0SyT2JCQQw78WTo99LYv4NiCuDU2Y8sUeuizdxzyY3e2_XXGkFif9EX6ZFmlZM-eqIf1DtaHhco8htg7oxylpBZDMI8emuq5NIhdWdUBqi0Iab122RCC3Ge2zvID5PuMTv-JY9aMxxAQ2jkOEdF6BtGgB7n76l4gpsvVKZ5ItVMp4ceLtODhSlFxiGhIO35cCcQmsQG5BbkttptyIPcfIJqy5DuIDYhu6UF0IDY82sI4gZjInUB0X3KLxDl6nGI2PzhENzsuPxMuqUB7mLNvD98qsZ7x_rKV-h_Q7u7_7agQ5AEfL2RWZ_i3GXXwaQL1N_DVo6_ksN6dgxmCY1gfQGxG5msqSokjiOMMLUM8gzj-BeJ47wZzv_32y0fR6ivPN3K5TyFHTUVdua0bkNvyQ4oxxPLig3-bUsXSjkwY6USRvCbkgKVrCKKd6mxRK-8D42C9KajCZ0g4YfaRylkwr5BjCCDaVwvqBqHd408EQ3x2aT-_rN_x7_9Ra--UP-NJWZdKHjr4G0VGaKoHNFUxQVM9P1X2Q2YcVUJfXMuZtZ4TqiFkRh7ph3NTYYjz5tW-Yn3yJxv8En9lPBG5hM7-QWiLLAkNmaytP09skVJ2jCqhwulbn_zLheml6WSnFtTXrVjJRmw6uRj7tdFmkGYwbS0rampdqXaoB2NOTaXbVi1sLyqxqjZCiHpVS7lslKrrbtOtNtQ0HZ1gVdFFWbd07nYpJ2VhU8rU19W6le3CqYFcmi4PIXTRD4Qo90jsS8DbkM8JVpWzidMnBVt21D_lHmhUN1vG2d4oninhs7SPWSXlzbT9iXQJ_xzJY05FJ7pfndWWMQy_k2a8qqguxDTJPw2-yhzmoS665ej6bzNheczDUocLiGNJeH68XWMonCCOkwAJxHHW4NaLfwIAAP__s3aGrw">