<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62531>62531</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`auto(x)` fails to be recognized as decay copy in some contexts (cannot compile libstdc++ 13.1.1 ranges)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
davidstone
</td>
</tr>
</table>
<pre>
Given the following presumably valid C++20 code:
```cpp
int f() {
int x;
return (auto(x));
}
```
clang rejects with
```console
<source>:3:15: error: type-id cannot have a name
return (auto(x));
^
<source>:3:18: error: expected expression
return (auto(x));
^
2 errors generated.
Compiler returned: 1
```
See it live: https://godbolt.org/z/7qGf7qjf1
The effect of this is that including `<ranges>` from libstdc++ 13.1.1 fails to compile.
A slightly more reduced version:
```cpp
int f() {
int x;
return auto(x);
}
```
Causes clang to fail with
```console
<source>:3:9: error: 'auto' not allowed here
return auto(x);
^~~~
1 error generated.
Compiler returned: 1
```
See it live: https://godbolt.org/z/59dYojYs7
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8lM-SmzgQxp9GXLrGBRICc-Dg8cR5gN1LjkJqQFNCIpJwxjnMs2_J4MTJzs7-qa1QlK1qyf193f61RAh6sIgt4Y-EP2ViiaPzrRJnrUJ0FrPOqUv7UZ_RQhwRemeM-6LtALPHsEyiMxc4C6MVHAl9JPSR5iCdQsIOJH8i-e2zytdXzvMa0TZCT-ie0AZI_Xg73KT4C2HfAx7j4i0QuhdLdITuXwht0vvtTP30k8i9sjTCDuDxGWUM8EXH8W1fzgZncIuyY3CLl0jYB8IOjLBDwQk7AHrvfFrEy4wPWoEU1roIozgjCLBi2jLA9vyteXjrIfzDXxvZ_2AEX2aUEVVaeAxBO_tvHXxTo2vaAANa9CKi2q0bRzfN2qDfkqFKysU7Tf8NEXQEo88JBBhjnEMigp4IPQ1Odc7EnfMDoaevhJ7qzx_7-vNzX9zn-H1EwL5HGcH1EEcdQAeIo4igrTSLShQmXXb0wg4YUo-qHHrvJjC6C1HJFUko2K7YFdALbQJEB3KtZ3cvd4Bg9DBGc4HJeQSPapGo4Iz-2tT_m-f7f-OfkXwUS8AAK9DRXcv570A3P2BEaL0aqiHxLNKUo4IR_Q3od2z_md7X19d1q1glfjlRvFGf3POnUGeqZaphjciwLao9K0pWlk02tnzfVV0neNftOZOFLGlVqZIrwbFuVMUy3dKcspznrGh4Xja7npVlXfe05znnJS1JmeMktNkZc56SdqZDWLCtKGdFZkSHJtwuVt-mQw_dMgRS5kaHGL7_LOposCVVft_cRPKN1y7hKN1g9VdUIAIolOIC0s0X0BaCmxCksxFfYkiTvt1KG-ZvD8M2M7TJFm_an_qp47h0O-kmQk_J5vb1MHuX7lFCT9dSA6Gna7V_BAAA___ertAI">