[Issue 23346] New: ImportC: pragma pack is not popped
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 19 03:56:06 UTC 2022
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 at puremagic.com
Reporter: dave287091 at 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).
--
More information about the Digitalmars-d-bugs
mailing list