<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122645>122645</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang 13 to trunk accepts implicit move of parameters in C++17 and not feature flag
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
beached
</td>
</tr>
</table>
<pre>
The following code is not an error in clang but isn't valid to my knowledge.
```cpp
template <typename Pointer, typename F>
constexpr auto or_else(Pointer &&p, F &&f) -> remove_cvref_t<Pointer> {
if (not p) {
return FWD(f)( );
}
return std::move( p ); // not needed in clang 13+
}
std::unique_ptr<int> foo(std::unique_ptr<int> p) {
return or_else(std::move(p), [] { return std::make_unique<int>(42); });
}
```
https://gcc.godbolt.org/z/TzWf6Eqov
The move on p isn't required as of clang-13 while compiled with `-std=c++17 -pedantic -pedantic-errors`. The macro `__cpp_implicit_move` isn't defined either.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8U8GO4ygQ_ZrKpZQI49hJDj6k0-3zHkaaY4ShbLONgQac3p6vX-E4aWl2NRISJOZVvfd4JWLUgyVqoHqB6nUj5jS60HQk5Ehq0zn11fwYCXtnjPvUdkDpFKGOaF1CYZFCcAG1RWmEHbCbE-pogR8S3oTRCpPD6Qvfrfs0pAbaATvnVbP7kt4DOyeavBGJEMpL-vJkxUT4l9M2UQB-wed_LZRvwM7S2ZjoHx9QzMmhC1cykYAfVwwCr4HXPmPb9UcP_IRbKN8w0ORudJW3QP01QXl5dCrfEA4vwM6IiLpH4Mcs02fk-iFQmoPF9ucr8GMuCfyIeSsfODi8rqf1bkwKyjOU59w1X_crABF4C7xdvLREitS3k0UJPJe8lwN2fpaZrf6Y6epTgPKibcq0e-eAH_945X9UfPv2O0e_KLvgPRYZ9l814p2u90bPJsCPe76Ky8QfvqwiHo9-FzSm5GOutZgwSLkbnOqcSTsXBuDtL-Dtj18_-_rtw93ukBzFzBCdRf8MWqCPWQdSKCK6_u7ftijxc9SGULrJa0MKP3UaEWq2XSS8yuwvfykOuPWkhE1afp-2S64j1GyHuHQVMriMvl6l91c9eaOlTtfFr5o9uSjqtSWFpNNIYbdRTalO5UlsqCkOZX1g1Z5Vm7HZH2spqKuFZHVFnDp2EHQ6sUpIxsSp2-iGM16xouDFsWCs2nXVSciq6oWqe1HQHvaMJqHNzpjblC3b6BhnagrO6321MaIjE5e55nyxBDjPIx6aDNh28xBhz4yOKX6XSDoZah4JzMObwmzfUUhJPkV86F5foUcvgpgoUYg5upenp8KqJdY9iTQHwt6IYTMH0_z26jqNc7eTbgLeZhbrtvXB_U0yAW8XVRF4uwq7NfzfAAAA__8JrHTM">