June 09, 2024 [Issue 24594] New: ImportC: Packed struct has wrong layout | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: tim.dlang@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 -- |
Copyright © 1999-2021 by the D Language Foundation