<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/146973>146973</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[aarch64][win] Applying alignment to a stack object causes a mis-compilation when using exception on Arm64 Windows
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AArch64,
platform:windows
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dpaoliello
</td>
</tr>
</table>
<pre>
Given the following code:
```cpp
// Large object: alignment seems to be important?
struct alignas(128) BigObj {
int value;
// Destructor so it's kept alive.
~BigObj() { }
};
// Exception type need to be large enough to not fit in a register.
struct Error {
int value;
int padding[3];
};
int main() {
BigObj bo{};
try {
throw Error { 42, {0, 0, 0} };
} catch (const Error& e) {
return e.value;
}
return 0;
}
```
This program crashes when built and run on Arm64 Windows:
```pwsh
> & 'C:\Program Files\LLVM\bin\clang.exe' .\test.cpp
> .\a.exe
> $LASTEXITCODE
-1073741819
```
The `alignas` seems to be important: if I remove that and replace it with a very large array within `BigObj` then the issue no longer reproduces.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VE2PpDYQ_TXuS2mQMQ00Bw70V7TSRBspoyTXwtSAd4yNbNO9fclvj0zT26NVEgkBLpefX5WfH3qvekNUs3zP8uMG5zBYV3cTWq1Ia7tpbXerf1EXMhAGgnertb0q04O0HbGsYXx5Cn5_5DTFoTgzcYZXdD2Bbb-RDCxrALXqzUgmgCcaPQQLLYEaJ-sCmsCyM-OND26W4Z6LnoldKnZMVLBX_df2G7Byz3gDAKBMgAvqmVj2CK37HukOYh14CyowUXr4oGlBvVCyZv99h2R3fFbugZXHyL483iGflZy-S5qCsgbCbSIwRN3KXi81krFzP8SQsQHeVQBlAMFRr3wglzzrOjln3f9UEccTdp0yPcv3GcsfXD6RijkjKvNkvoKtPWptDH1aEOeCuz0yw-Ds9ckEtoKJQ_zj8bu-yiP8gFh6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