<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115186>115186</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Miscompiled program with `--target=wasm32`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tekhnus
</td>
</tr>
</table>
<pre>
Here is a simple C++ program:
```
struct BigClass {
char data[400000];
};
struct Class {
char big_data[400000];
int value{33};
};
Class glob{};
extern "C" int _start() {
glob.value = 42;
BigClass s1{};
return glob.value;
}
```
When compiled and ran with `wasmer` runtime, it outputs "0" instead of expected "42":
```
+ clang-17 --version
clang version 17.0.6
Target: aarch64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /nix/store/glzjy0xq2xhmwg6pc8c1pdk7gln127wj-clang-17.0.6/bin
+ clang-17 -std=c++20 -pedantic -Wall -Wno-unused-variable --target=wasm32 --no-standard-libraries -mbulk-memory -O0 -o main.wasm main.cpp
+ wasmer main.wasm
0
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VF1vqzgQ_TXmZWRkzFd44KFpFO0-rPblSn28GvAU3BqbtU2S7q9fEbJt7m0bRWB8PGfOzBwZQ9CDJWpZuWflIcEljs63kV5Hu4Skc-qt_YM8gQ6AEPQ0G4JHJvdM7mH2bvA4sfyBiQMTD6wSt__1M0S_9BH2eng0GAKwer8BAP2IHhRGZOW-EOuPlQeW33BW363vqb7m6fTw81suAG0jnNAsxOp9nv_C_SnPlmAwrluTfILpEslbYFI-MimvzD9DRB-Z3DHZ3CtbOdJrWmD5AQr5oei9ISH7LQuAp7h4exf9i9ivurw9n0ay0Ltp1oYUoFXg0cJZxxFYJc4YJvKsEuAXG_VETD6CjuCWOC8xrAWJraAQCRW4Z6DLTH0ktWKFZFJ-N-XVCL1BO_CsBs5P5IN2dsOu-3DbgqxORVptyA_0A0WWPwCi78eq4DjPhrhCf9ZW5mmV3vh_jH6VNDlFZj0_u6AvG_SnDRGNIXXQfoWYPFp9YfIYovPE5HEw_768ics_8jJO56Ga-12fzeq1HozNZH1-4f8LvwqTx07br4oKUbH80G-ulwL4TApt1D3wJzQG-JN1fLFLIMVP6DV2hoDzeKvxsLY_l8C5dTxEtAq94kZ3Hr2mAHzqFvPKJ5qcfwP-twDuYEJt0zVwW_Xz_KFsG-fHkQ0Rv40nUW2umrzBhNqszkWTFUUhkrFVVd4XqLAviwLxGZ8pl0Upm6quxa6gLtGtFLLIMlFldZ6XTbprnptOVpkqVCGaLGOFoAm1SY05TanzQ6JDWKjNsjLbVYnBjky4XilSWjrDFV09VB4S365BvFuGwAphdIjhgybqaKj9S4d3K9_umHcrf2rrWuniTTvGOIfVpPK4Tl7HcenS3k1MHlf624vP3r1QH5k8XkUFJo831adW_hcAAP__vE1-Ig">