<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/101614>101614</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] libstdc++’s `std::forward_like` doesn’t compile
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
c++23,
libstdc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Sirraide
</td>
</tr>
</table>
<pre>
Attempting to use libstdc++’s implementation of `std::forward_like` (https://godbolt.org/z/cGK1bsjzM)
```c++
#include <utility>
void f() {
(void) std::forward_like<int&&>(1);
}
```
results in this error
```
<source>:4:17: error: function 'forward_like<int &&, int>' with deduced return type cannot be used before it is defined
4 | (void) std::forward_like<int&&>(1);
| ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/bits/move.h:93:3: note: 'forward_like<int &&, int>' declared here
93 | forward_like(_Up&& __x) noexcept
| ^
```
whereas the same code compiles just fine if `libc++` is used. GCC of course compiles this just fine with `libstdc++`.
I haven’t looked into this too much, but it might have something to do with the fact that we treat `std::forward_like` as a builtin, and libstdc++’s declaration uses `decltype(auto)` as the return type of `std::forward_like`, which might be confusing us somehow.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU1v2zgQ_TX0ZWCBJm1LPvjgOnWxWOxpseeAIscWW4oU-GGn_fWLkZTEadpgD2vQFESK8_HmzaNKyV484p5tPrHNw0KV3IW4_9vGqKzBRRvM9_0hZ-yHbP0FcoCSEJxtUzaaiU80PgvWcLbbJbD94LBHn1W2wUM4A9vylA2TByYP5xBvKppHZ78h23JgoulyHhLtihMTp0swbXC5CvHCxOkHEyf95c9Vm77--IuJHeMPjB_Ylk_j2fu0KqT12hWDwOSxZOts_s7k53l3nK_BGjgz0TCxA1bPJwGAAqFNWv91sPJofWZiS0N-ZqJZUTzy2Xn98FNs02vE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