<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99914>99914</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Improve diagnostics with incompatible VLA types
</td>
</tr>
<tr>
<th>Labels</th>
<td>
quality-of-implementation,
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AaronBallman
</td>
</tr>
</table>
<pre>
Consider an example like the following, compiled in C++:
```
void func(int n) {
int grp[n][n];
int (*ptr)[n];
for (int i = 0; i < n; i++)
ptr = &grp[i];
}
```
https://godbolt.org/z/oET6jjjzj
This emits a very confusing diagnostic: `error: incompatible pointer types assigning to 'int (*)[n]' from 'int (*)[n]'` and users are understandably confused by it: https://discourse.llvm.org/t/clang-pointer-assignment-error-message/80265
It would be better to identify when both types are VLAs with the same bounds, and instead of repeating identical types, issue a diagnostic specific to VLAs. e.g., `error: incompatible assignment of pointers of variable-length array type 'int (*)[n]'; consider using a typedef to use the same variable-length array type for both operands` or something along those lines.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE-PqzgM_zThYrWipoVy4NA_W-lJ7_j07oEYcDckbBI62_n0q0Bn2xntToVEShz798ex9J47Q1SJ3VHszomcQm9ddZDOmqPUepAmqa26VydrPCtyIA3Q33IYNYHmPwlCT9Bare0bm07gCRo7jKxJARs4CTzGJzuI9CzSg8jTxzP_vVlW0E6mEbhnE8AILEEUx2UXACB-7dwodkcjduePV_YlQuBe4GEMTmD5NeYZ2VoHj0IMIjtDKrLjvDyBmZcPtFg-D8XfGNwcLzBfsPCnAsX5P8n1IYw-MseLwEtnVW11WFvXCby8C7zYP37l1-v1_fqK81fPHmjg4EHCjdwdGmvaybPpQLHsjPWBG5EdQOQpOWddXLOJosvAtSYYLZtADsJ9JA-LwfF4sCCweMr1ohUW0Do7fLMv8hSkUTB5ch6kI5iMIueDNErW-gMmKajvwCGC-sxfsW_s5Dyttb4NDxmCwEujpelWD9CrBe5AJqxmdquBvJcdCbzsU8x3r1r9CPBmJ62gJqgpzJwtsCITuL3DW08Gahv6DyUcwe-fBw9vHL_1BF4OBLWdjPKxcSM_Nj6QVGBbcDSSDFG5JWUj9ZIpxrL3E4F88QT8SA233EQQsc4aaN2tY_D_WvVkGws-NPBxfZOOZa1ppcl0oQfpnLzP5b8zKTtGH5Z7uvSMnM8oaiOqydOT9zcV4kWZhbMjORnVyVOwDrwdKPRzWm1jR_XWxylgyK8TVWWqzEqZULUpcJMXWbrbJ321Q9zUSm7yXG1J5ttmkxdtvlGtyreqpCbhClPcpgXiZh_PrFWBuKuxaFJUadZsxTalQbL-t3OSWf2qLMvNNtGyJu3n-YX41yQ1h_vKtiuOIypKKwNbIxAFngTi3G4iOzyN83Fvd05cFfOv6qnzYptq9sE_KwYOmqofw-jsjV5cf3TTJ1d__zwsjZJMTldfxgCHfqrXjR0EXmL2x2s1OnulJl6ImZwXeFn43Sr8JwAA__-NjMti">