September 19, 2022 [Issue 23346] New: ImportC: pragma pack is not popped | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23346 Issue ID: 23346 Summary: ImportC: pragma pack is not popped Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: ImportC, wrong-code Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: dave287091@gmail.com It seems like #pragma pack(pop) in a C file does not undo a #pragma pack(push). For example (on a target where sizeof(long) == 8): #pragma pack(push, 4) struct Packed { int x; long y; }; #pragma pack(pop) struct NotPacked { int x; // should have 4 bytes of padding long y; }; _Static_assert(sizeof(long)==8, "long is not 8 bytes"); _Static_assert(sizeof(struct Packed)==12, "sizeof(Packed) != 12"); _Static_assert(sizeof(struct NotPacked)==16, "sizeof(NotPacked) != 16”); // This static assertion fails. Compiling with clang passes the static assertions. I noticed this when compiling some code on macOS (which unfortunately uses pragma pack in some system headers). -- |
Copyright © 1999-2021 by the D Language Foundation