<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70319>70319</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [LoongArch] An error when cross using clang++ and g++
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Ami-zhang
      </td>
    </tr>
</table>

<pre>
    - Testcase

```
// foo.h 
struct A { };
int foo(A a, int i);
```

```
// foo.cpp
#include "foo.h"
int foo(A a, int i) {
  return i;
}
```

```
// main.cpp
#include "foo.h"

int main() {
  A a;
  return foo(a, 5);
}
```

- Compile and run

```
$ g++ -c foo.cpp -o foo.o
$ clang++ -c main.cpp -o main.o
$ ./main 
# Expected output is 5, but actual output is a random number.
$ echo $?
120
```

- compiler versions

```
$ g++ --version
g++ (GCC) 14.0.0 20230926 (experimental)
```

```
$ clang++ --version
clang version 18.0.0 (https://github.com/llvm/llvm-project.git dbe8def9ccd1b8d50e12c8ee66ee509a86e72510)
Target: loongarch64-unknown-linux-gnu
Thread model: posix
```

And clang 17 has the same issue.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVMuSqzYQ_Rp50wUlmveChR9xNlneHxCiDUpAovS4d5KvTwns8cws5s5UuYzoPlKfc1q0cE6Nmqhj5YmVl4MIfjK2Oy4q-W8Sejz0Zvi3S-AHOS-FI8YvjB_v_xW___ZXvDK8ws2YdII95LwN0sMRWH0CVl9YftoTSvsIZNgcQTA8Qwwohu0r4uPhv6ko1_URy5WWcxgIGOJGhiH-pmrkt0MALPlgNagnk_rybUqLUPprnJ7M4h6GzQc6kWn-kdwuYpNQvjPtU6oJnM2yqplA6AFs0J_qKGBkeGJ4gkQ-LIbEbEvzBMlZ6DfAh_CI3NZvoCnDa4zBqyvwx8tK0tMAJvg1eFAuCjpDHzwI6YOY32QEWKEHs4AOS082fZ5McjLAsGD5dQ9myD81Qu5GWPhJ1imj3VetSO4b9tQjzLD583yOncuKlKcckGPOW6xihl5Wsmoh7cUcm_WNu_TB3vfFt9RDAGTNVphhM3m_Opbfr-Ko_BT6VJqF4XWefz4eyWrN3yR9OioPQ0_NQLdWyiHrm6HklKFsiKqKqOStaCqqscz4K_0fwo7kWX6E2Rg9CiunqkiC_kebXzqZlQ4vyajDHTxZEgMsZqA5blmNUy-f2HDUw64bshom4cBPBE4sBMq5QOlh6PKhzVtxoC6r2iZHjpgfpi4felnUxY3jTSK_NVXW3sq2KEXb1re8EQfVxcZkHKssy2uOaU110RDdKt63ktqGFZwWoeY0WpQaOx62kl3N86w9zKKn2W2jEvHeGYxT03abpX0YHSv4rJx3zxO88vM2X_-KVh2tnFh5gaMGstZY-DWRBmmNcxCc0uO7lscP9b4-BDt33-stw-tG3zG8bgr-DwAA__9kyqJr">