<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63257>63257</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang: ABI incompatibility with MSVC on i686-windows for `__declspec(align(N))`, with N <= 4
</td>
</tr>
<tr>
<th>Labels</th>
<td>
ABI,
platform:win32
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
erikdesjardins
</td>
</tr>
</table>
<pre>
For the following three struct definitions
```c
struct NoRequestedAlign {
uint64_t x;
uint64_t y;
uint64_t z;
};
__declspec(align(1))
struct RequestedAlign1 {
uint64_t x;
uint64_t y;
uint64_t z;
};
__declspec(align(8))
struct RequestedAlign8 {
uint64_t x;
uint64_t y;
uint64_t z;
};
```
when passed by value:
MSVC passes `NoRequestedAlign` and `RequestedAlign1` on the stack (like `byval`), and passes `RequestedAlign8` indirectly.
Clang passes `NoRequestedAlign` on the stack (with `byval`), and passes `RequestedAlign1` and `RequestedAlign8` indirectly.
It seems that Clang passes a struct indirectly if there is any `__declspec(align)` requested alignment, but MSVC only does so if the requested alignment is > 4.
Demo: https://clang.godbolt.org/z/fsn78PhxT
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8lMtu6zYQhp-G2gxiUNR9oYUvFZBFg6Itug0ocSQxoUhXpOIoT19QdupLHQRdnAMIsj0czv_xn6G5tbLTiCVJNiTZBXxyvRlLHOWrQPvCRyG1DWoj5rIyI7geoTVKmYPUHbh-RATrxqlxILCVWjpptCV0R-iapPT4NMffp7wn8zv-PaF1KNZKdhpItjkmAExSuzR-dvBOov8G53vBj3-DJNudvy_v52eBjbJ7bAjLuRcjLA8JK_xzyXRNFF4g_Qyi_Fui_IcQffbnEvDQo4Y9txYF1DO8cTUhidaXKb_-8df2mGKBpPS2nySlwLXwSze2-hWjlxmyjjevQFiu5Cv61Hp-48qzeCu2S4GzxI0Zvo7UQo7YODWvjlRbxXX3Ddat-EG6_n-Kh18e7z7W8f3owCIOFlzPHVyh8s_7c94KsvWcI4K0wPXste4NTuEVx08IWKIDaufPUE8OlkYZrWYQBi1Ycyp8b4-XItEvEF9x73AwJFpD79ze-jFgFWFV4_lXnRG1UW5lxo6w6oOwqrU6y3_r3_8MRBmJIip4gGWY5mkSJgnNgr4MkVHO24yHRZLTsKVZHhc1r5sopWld00CWjLKIpmHIaBTG2SppUhHzgrZNQxkrBIkpDlyqlVJvg9cOpLUTlmnEkixQvEZll_8yxtabR8IYYVvC2F5x15pxINH6IHXE_EKyC8bSl3mop86SmCppnT0XdtIpLJdmeQ_Wm0eQujHDnjtZSyXdDMsAnWwGmebpw0FqYQ4WWjN-1bb86XTf_cBtjzWegERbEu0gDqZRldd-d9L1U71qzEBY5fFOHw_70bxg4wirFhMsYdXiwz8BAAD__5dayz8">