<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61187>61187</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Wrong-code] large global array will be init to zero
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
youngbe
</td>
</tr>
</table>
<pre>
For code:
```c
#include <stdio.h>
unsigned char x[(unsigned long)8 * 0x40000000] = {1};
int main()
{
printf("%hhu\n", x[0]);
return 0;
}
```
Compile with:
```bash
clang test.c -mcmodel=large
```
Run result: `0`
readelf to a.out, x is in bss section.
For code:
```c
#include <stdio.h>
unsigned x[(unsigned long)2 * 0x40000000] = {1};
int main()
{
printf("%u\n", x[0]);
return 0;
}
```
Compile will be failed:
```bash
$ clang test16.c -mcmodel=large
error: invalid number of bytes
error: invalid number of bytes
cerror: invalid number of bytes
3 errors generated.
$
```
clang version : 15.0.6
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lM-O-yYQx59mfBnFwhD_O_iQjZsH6KVnMGObCkMEeH-bPn1lJ9qNttpVK20tyxbMn-8MH0DGaCZH1EH5AmWfyTXNPnQ3v7pJUaa8vnUXH3DwmkCcgPXATlCx-zs8xlwYN9hVE4I4x6SNz2cQvz2s-3d1u5DGYZYB3zY53rxPWu8m4G2DwE_I3o7s_kDZI4geoX4poO5BvDynNC7hIo0D3gBvH5b64YKIeA3GpXE3c-DlPK9Qnt0-OO8lbAJbqHgKCpTW4JB9iNX9p7afizj75Wos4S-T5n8ukJJxvk8NVroJE8WUD3hYhsVrsiB6K8NE3-T_fXUYKK42gTghVOyzQyCpyY6YPMrcr2nvDU1E41DFiJGGZLzLn2N-lugXMPkPwvxE8n_laC0qwlEaS_o7osCP-EG1qL7kSiH4sNEz7lVao9Gti6KAfkR1SxT_i9fw79wE7n4RJ3IUZCKdvxf9zSLc23mlEI13uKkUZc7yKtOd0K1oZUZdUdV12zYVq7K5U7qRRHKsq2YUxVAVNI681bpqmporGjLTccYFE6xk1VHwKtdNXegjUyVvK0VUwpHRIo3NrX1dch-mzMS4UlcVRVNnViqycb-cOHf0C3fjRr7ss9BtMQe1ThGOzJqY4keWZJLdb7U_gnfTYd_tZY87FpysV9KiDEHe3okbZ9J2iv6i4LM12G5O6Rq3HcAvwC-TSfOq8sEvwC-bzON3uAb_Jw0J-GUvLgK_7MX_HQAA__8UzYQ7">