<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/119352>119352</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
_Complex _BitInt is inconsistently/incorrectly lowered
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:codegen
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bevin-hansson
</td>
</tr>
</table>
<pre>
See the following program: https://godbolt.org/z/YhdKov4x1
There's a number of inconsistencies in how this is emitted.
* `sizeof(_Complex _BitInt(144))` is 48, but the actual size of the declared variable is 64.
* A struct with two `_BitInt`s has a size of 48, both in sizeof and allocation.
* The code in the `set` function is wrong:
```
%arrayidx.imagp = getelementptr inbounds i8, ptr %p, i64 32
store i144 1, ptr %p, align 8
store i144 1, ptr %arrayidx.imagp, align 8
```
If we allocate a memory area of size 48 and then perform these stores, we will write outside of the allocation (32 + 18 = 50).
Compare this to the `set2` function, which designates the imaginary member at offset 24.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VMGO2zgM_Rr5Qkxg007iHHzItAhQ7HF72VMhy7SlhSwFEh1P-vULOpntdA4FhCQSqMf3nh6jc3ZTIOrU_lXtvxZ6YRtT19PNhRerQ84xFH0c7t3fRMCWYIzex9WFCa4pTknPqj6DZb5mVZ8VXhRepjj00fMupknh5afCyz92-CvemrdKlWdVnr9bSqTwmEFDWOaeEsQRXDAxZJeZgnGUwQWwcQW2LoPLQLNjpmH3gFB4BnUos_tJcVTY_vgS56unN_jx6vhbYIVt1TQKT7IOpQA0rcIv0C-86dCGF-1BAKS5HA1kvE40wE0np3tPcuvQ7J7tzpA5LYZhdWyB1ygE3tsdygxWi6B3xGe7yFaUPIiCDgNo76PR7GJ4R_5uCUwcSAqFiKCRYMK4BCOVwmRNMUxicnkGKXmubYd7nZK-u-Ft52Y9XUHVX2EiJk8zBb5yAhf6uIQhg9uIyZHC_VV-u0MDNW5ImWMicFXTQPW5THs3BWj_VPc7i8-Xfif9bYSV3t0g0DDTHNMddCItBm5GNu3mGVsKcKU0xjTLJtODQZYWK8HqvIc1OSaIC2c3_P-ov9wGhW2NoPAVqnYzaF8qPO0e1ORDMqQTPSLH8cNb4MfH2HpaZywMJOOjmfJWK6Jd0OkuUiTVmiGOYyYG3GJUDF09nOqTLqirjnXdYnMssbCdNsb0x2bAduypr_qRxpLK6kDj8UR9rwvXYYlNhVVZnvYt4q5q2rHS1Xgw7fFkDnvVlDRr53fe32YZvcLlvFBXVad6j4XXPfm8jTmi8XpLkmRuoqAQZfZTJ1df-mXKqim9y5x_gbFjT93nKZNYfhhb9neFFzlIiQz7O_i4UqKhWJLvPv1JOLZLvzNxVniRNs-vl2uK_5JhARIBWeHlqeHW4X8BAAD__6tHgHo">