When struct is passed on the stack and alignment of struct is 16 bytes compiler does not align the struct properly. Here is a comparison between ldc, dmd and gcc. Both ldc and dmd miss the alignment.
https://godbolt.org/z/xKc8WK
D code:
```
align(16)
struct s { long a; }
extern(C) void foo(int, int, int, int, int, int, s, s);
void bar() {
// push 10
// push 7
// call foo@PLT
foo(1,2,3,4,5,6, s(7),s(10));
}
```
C code:
```
struct __attribute__((aligned(16))) s { long a; };
void foo(int, int, int, int, int, int, s, s);
void bar() {
// push 0
// push 10
// push 0
// push 7
foo(1,2,3,4,5,6, s{7},s{10});
}
```
However alignment starts to work if you replace 16 with 32.
https://godbolt.org/z/6r7GbW
Issue for ldc: https://github.com/ldc-developers/ldc/issues/3557
Comment #1 by robert.schadek — 2024-12-13T19:11:24Z