[Issue 24594] New: ImportC: Packed struct has wrong layout
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jun 9 14:25:17 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24594
Issue ID: 24594
Summary: ImportC: Packed struct has wrong layout
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: tim.dlang at t-online.de
```
#include <stdio.h>
#include <stdint.h>
struct epoll_event
{
uint32_t events;
uint64_t data;
} __attribute__((packed));
int main()
{
printf("size: %zd\n", sizeof(struct epoll_event));
printf("data offset: %zd\n", &((struct epoll_event*)0)->data);
}
```
Output with gcc:
size: 12
data offset: 4
Output with dmd:
size: 16
data offset: 8
The type epoll_event is originally from Linux header /usr/include/sys/epoll.h,
but modified for this test.
The problem was found by comparing type sizes in druntime with type sizes found
with ImportC: https://github.com/dlang/dmd/pull/16571
--
More information about the Digitalmars-d-bugs
mailing list