<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/100542>100542</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Explicit object operator() copies movable temporaries
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Fedr
</td>
</tr>
</table>
<pre>
This program
```
struct A {
A() {}
A(A&&) = default;
void operator() (this A) {}
};
int main() {
A{}.operator()(); // ok
A{}(); // fails in Clang
}
```
is accepted by GCC and MSVC, but not in Clang, which tries to copy `A` in `A{}();`:
```
error: call to implicitly-deleted copy constructor of 'A'
9 | A{}(); // fails in Clang
| ^~~
<source>:3:5: note: copy constructor is implicitly deleted because 'A' has a user-declared move constructor
3 | A(A&&) = default;
| ^
<source>:4:28: note: passing argument to parameter here
4 | void operator() (this A) {}
|
```
Online demo: https://gcc.godbolt.org/z/YEKh8G71o
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlE2vqzYQhn-N2YxO5Nh8hAULDifcRVV10apSl8aegFuDkW1ymy7ub69MkpOPm8W9ESLE4X3nmfGMhfe6nxArkr2T7CMRSxisq1pULumsOlV_DNrD7GzvxEjoB6E1yenlWn_64BYZoAZSvJ9XAABqwnaEleti8fG4XhOWr1cJhH-AwoNYTCD8Tn60WoGd0Ylg3dWK7UKEqZ9948NVfL7rKcAo9HQHcUewSjeP7pc7fwfCWsJasP98J_nunYPQxoOeoDFi6m8wr8qkPQgpcQ6ooDvBl6YBMSn49fc_G8Ia6JYAkw03M9bA10HLAYLT6CFYkHY-AclX5_je-vgIFqPx-mV8dM46wmuQwphop8fZaKmDOb0pNBi51gjSTucttQ7sAQgrasKKWzFiORv42bKsgk8lyfbfvl0weePt4iQSvie85oTXWcScbMAV95lJ-zt0uKJ3KMXi8YoLg_AgYPHo3hRKIxwqGO0R760uZPwuoR9qzoc8XmaREl6z3X0acxy0qQfh-mXEKcQdmIUTIwZ0MKDDm3_66f9TY_Cpun1edsJvk9ETgsLRRrIhhNnHrlk3r5dy01vVWRM21vWEtf8R1v61_2XYfSm2NlEVVyUvRYLVtmDbklKeZslQHSjNs6Io83zXIcsV52kpU8kLKhFVVya6YpSltGAZLXlJsw3jpRJCHqhM87zcbklKcRTabIw5jjF2or1fsNpSmqUsMaJD49djirEJv8L6L2EsnlquiqK3buk9SanRPvibTdDBYLX_99wzYLu_UYbnqko7xzEb7VF0BiHgOFsn4uglizPVU5F0GJZuI-1IWBvjXL7eZmejOWHtSucJay_4x4r9HwAA___55IXM">