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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Deducing this does not work correctly with move-only types.
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          slavek-kucera
      </td>
    </tr>
</table>

<pre>
    Move only types have to be explicitly cast to r-value for the move constructor to be used. https://godbolt.org/z/fabdhKKEj

```
#include <utility>

struct X {
    X() = default;
    X(X&&) = default;
    void operator()(this X);
};

void fail() {
 X()();
    [x = X{}](this auto) {}();
}
void pass() {
 std::move(X())();
    std::move([x = X{}](this auto) {})();
}
```
```
<source>:10:5: error: call to implicitly-deleted copy constructor of 'X'
   10 |     X()();
      | ^~~
<source>:5:5: note: copy constructor is implicitly deleted because 'X' has a user-declared move constructor
    5 |     X(X&&) = default;
 |     ^
<source>:6:27: note: passing argument to parameter here
    6 |     void operator()(this X);
      | ^
<source>:11:5: error: call to implicitly-deleted copy constructor of '(lambda at <source>:11:5)'
   11 |     [x = X{}](this auto) {}();
 |     ^~~~~~~~~~~~~~~~~~~~~~~
<source>:11:6: note: copy constructor of '(lambda at <source>:11:5)' is implicitly deleted because field '' has a deleted copy constructor
   11 |     [x = X{}](this auto) {}();
      | ^
<source>:5:5: note: copy constructor is implicitly deleted because 'X' has a user-declared move constructor
    5 |     X(X&&) = default;
 |     ^
<source>:11:24: note: passing argument to parameter here
 11 |     [x = X{}](this auto) {}();
      | ^
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVktz4jgQ_jXNpQvKlmwMBx9IHC5Te-cqSw3WRCBKD2bYQ377lkzMa8hmZ2r2MimXY4t-fN3f19DCe73ZEdVQPkHZjEQMnXW1N-JAr-PXKMmJUWvVsf7LHgjtzhwxHPfksRMHwmCxJaTve6OlDuaIUviQTt34IEwkXFuHoSPcJm9pdz64KEM67D2jJzXBLoS9B74AtgS23FjVWhMm1m2ALf8GtlyLVnVfvrx8hayBbPF-n2bv1-mVcb2TJipC4M8xaKPDEfjLtcspOa4QqqfTCSLiCtgM2ByBN6hoLaIJwO8-XwGb9tfHZgerFdo9ORGsO4UENgud9inC_GwLVXN57u-951poMwA5o1ud41xHSNmgfPreQ1kl66qBshmyiRjsEKZq7nzTySXpXnj_Q1IfVOKCLxJnp9pPIB7huDf-CVz34c7Q7pm9e-XP3kYnKZHLF3kGfFECXyA5Z116kMKYpC-9HWQ5VmQokEJp98cbGdo1AqtWwKpzTXmGUD3jlTQe1I29DZQvb28PYZUDqp0N1IO6z6z9FUAcALYkRfQ0gMJOeBRpTNxYkTTCkfphli6oyhvkn4l2sIXy5WENU-ALVl0XkfSidxsUbhO3tOsnfS-c2FIghx05umCZnuP_18m46etjsvPfQDawmRHbVgkUAR8nSACvBJFfterXxu66128P_z6ud_qvMvq5mj5R3VqTUad4g_Q-auZv7c6nxP8J49TzwIpfmqf_qcm336wjVXM153MxojqvWD7Lq4zzUVeLthU0Lakq5ypTRVnMcpW3-Xwm2qrMpsVI1yxjRVaxIs94xvmEOG9lwYqMZoKL6RqKjLZCm4kxh236ZR9p7yPVeZbxIh8Z0ZLx_Q7CmDRitwHG0jri6uQwbuPGQ5EZ7YO_hAg6mH5xee49ygYbUlGmhvbtUJZ8ajV-s-4VpXWOZBLHNx26nvXxZZ2ZjKIz9d0iokMX24m0W2DLlPX933jv7FeSAdiyr8IDW74XcqjZPwEAAP__NyalMg">