<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/90357>90357</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
pointer (to dynamic multi dim array) conversion is rejected
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
franck-behaghel
</td>
</tr>
</table>
<pre>
The below code is rejected by clang++ :
cat main.cpp
void init(int n1,int n2,int * data )
{
int (*array_2d) [n1][n2] =( int (*)[n1][n2] ) data;
for (int i1=0;i1<n1;i1++)
for (int i2=0;i2<n2;i2++)
(*array_2d)[i1][i2]=0;
}
I get :
main.cpp:3:10: error: cannot initialize a variable of type 'int (*)[n1][n2]' with an rvalue of type 'int (*)[n1][n2]'
int (*array_2d) [n1][n2] =( int (*)[n1][n2] ) data
note this is accepted by gcc and clang (as a c source) and by g++ ( as c++ source )
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0U02PgzYQ_TXDZbQRjEOAA4dko0i9914NZgJuHTuyTVbpr69MspttV6rUQzngB37z9fzMMZrJifRQH6A-Fryk2Yf-HNjpP94GmXmaxRaDH-_9r7PgINZ_oPajoIkY5HfRSUYc7qgtuwnoAHRAUHsoj1DuNSe8sHEbfb0-_ty8GRGNMwmoNS6hq4DeV0BPALTHkRMjUPcIgubwAJhDM6MF2nMIfP-NRqAOoT64CupjXgnqI4I6ArXf2DnZDxJ1uJYC9Spw9gGfvZkK1LEEdcjg3VUPtM741dvf-PTJp8ynB_oHf31-TAB1Tr32ZnJvz0Sf8x-fYH3_gpOkl8hfAqu9ArWvSlB7lBB8yECzcz6tihu25k9BxhsHw4MV9GdM96sgUPOvSgE1-GHSjOww3Ngu_yn0fz67b8o4nwTTbGJ2J2st16c7J62R3fhwac7KERk1Rr8ELTlX3s3ETwtTixwR9fP7QXxZshh7NXaq40L6qqm2VFdVtSvmXtS227asZMd1LWNHdK6VbqjtKj2qnS5MTyVtyy01VNZVvdtIWemuHutRd9y2bQPbUi5s7Mba22Xjw1SYGBfpu1LVTWF5EBvX-0rk5APXTaAsShH6HPM2LFOEbWlNTPGVJZlkpb9645Kslk0ex7vji9F4WWwyOJoLrieTBdHe3SRE4933q14swfZzSteY_UcnoNNk0rwMG-0vQKdc7bm8XYPPQUCntccIdFpn-CsAAP__PAxEmQ">