[Issue 21230] New: Incorrect stack alignment of 16byte aligned aggregates on linux
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 7 16:12:02 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21230
Issue ID: 21230
Summary: Incorrect stack alignment of 16byte aligned aggregates
on linux
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: mrsmith33 at yandex.ru
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 at 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
--
More information about the Digitalmars-d-bugs
mailing list