<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55968>55968</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang bug with handling of pointers to VLAs
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jeremy-rifkin
</td>
</tr>
</table>
<pre>
```cpp
void foo(int* ptr, int n) {
int(*arr)[n] = (int(*)[n])ptr;
}
```
https://godbolt.org/z/zf8E1cbar
This code is accepted by gcc but not clang:
```cpp
<source>:2:10: error: cannot initialize a variable of type 'int (*)[n]' with an rvalue of type 'int (*)[n]'
int(*arr)[n] = (int(*)[n])ptr;
^ ~~~~~~~~~~~~~~
```
The code compiles fine in C mode.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytUkuP2yAQ_jX4MtrIhvh18CGbZE89Vr0DHttsCViAU2V_fcd5KFW3hz0UDTDDPBi-D-X7S8eq_CZ6nll-YPnu7E0Pg_eMN8Ylxncwp8D4HsgCx3gLrH69hQKNa0xDYTJQVMvKV8fKAzBB815h9T5dpK0Fxb0Gqw935dHJzZxSmiMTlPhGMvpeeZs2PoxkfaxzaI6FVjLcs6_r98lE0L5HoF1qjXPCHtQFRq1BLdS_T6CtdONa-Y_EzzAwsY9-CRqZOFIwp1nktACG4MOqaOnWcsaZZKQ1HwgSzjIYqSyCHyBdZiQM6hW3zyDU8MukCaSDcJZ2-UrG_wMdHoOVx6deH78q_yLswQDeCND-NBuLEQbjiA4HezjR-SbrO9G3opVZMslit1_ZIG7GGx6TdL01dEJwzJ5egiFC8vDj2y5mS7DdX_-Ccha1ocvIsPb82F7m4N9REw5vJsYFIyll2VZNNnVVXVZ9K-tGVblqsNpKJZpcIKqyKEvkmZUKbewIOkIuMx3POc-rvOViW5Vi0xTFwDEfmm2x5SgGts3xJI3drBevPzQL3bUHelQkpzUxxadTxmhGh_ioL5c0-dC9Y8DT5SWY4adx2bXp7trxb4kdCc0">