<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/70890>70890</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LoongArch] ABI mismtach between clang++ and g++ against empty union
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
SixWeining
</td>
</tr>
</table>
<pre>
- Testcase
```
// foo.h
union U {
};
struct B {
U u;
int i;
double d;
};
int test(B b);
```
```
// foo.cpp
#include "foo.h"
int test(B b) {
return b.i;
}
```
```
// main.cpp
#include "foo.h"
int main() {
B b;
b.i = 10;
return test(b);
}
```
- build and run
```
$ g++ -c foo.cpp -o foo.o
$ clang++ -c main.cpp -o main.o
$ clang++ foo.o main.o -o main
$ ./main
$ echo ?
0 (expected 10, but actual 0)
```
- compiler versions
```
$ g++ --version
g++ (GCC) 13.0.0 20221013 (experimental)
$ clang++ --version
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 1abd8d1a8d962a14ca96e19c0f6da4f9ac394d0a)
Target: loongarch64-unknown-linux-gnu
Thread model: posix
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVF2PozYU_TXm5QpkG5KYBx4mE6Wq1Lfuqs-2uQG3xo78sTv77ysI-Zp2ZzUSAvv6-HDOMVwZoxkcYkc2e7I5FDKn0YfuT_P2Fxpn3FAo3__oSviCMWkZkdADoS_rfUvX6zLlR8KPcPK-Gi-V7Ix38BXIbr9CdgdS7x85YgpZJ9jfMQBfId9QAMYlMA_z3mdlEfo70X9I5y0JYyJc7EER3t7X30n-hQ99PsO1WBunbe4RCOcXj5x_-NJHSwFTDg5UZZ5kf1bTJI37tKh5E-HinaJZ4z1UVRkg9QEYfSiuoldTzzl-KL4ElY3tQboeQnYf-mpgIHxP-B5Kfcu89MvQ30HaSvcAvAVR-sv4J9CFZUVcsXdkRfjxuYJ69EDq46VCgXCBb2fUCfs5G_4KKieQOmVpgc6JfJSC9tPZWAzwDUM03sVfZ1Cu0MvStUy4-O31dT5BVle0osAp54yy-iowmAldkvau6P-Te6Zflq7igImFmnAxpnSOpF6_usGkMatK-4nwo7Xfro_yHPzfqFM1mARMql70TIq-3XLJGi3bLbJW09O2l82plbpum57Km8AvMgyYSP0C1ns3yKDHbVNm94_z311pjctv5eDyCh4Dyh4m36Odt5x9NG_vwiz6ru7bupUFdmzbCkHFbiOKsduIhu3ojm-l0A3SWjWyUYLuWKM4nmRdmI5TXjNGGa1Zy0SlGiUaqlqxO7UcN4w0FCdpbDXbrnwYChNjxm5HRUsLKxXauHRQzte0-dxMQ7fEpPIQSUOtiSneGZJJdmm7f8z2X4IeyeYAL_vfYTJxSlKPoDB9R3RPJzj_UrfxII2LCXA6px-wNNsiB9t97vgIPy5uIuHHxdC_AQAA__9V-qiF">