fix Issue 23346 - ImportC: pragma pack is not popped (#14490)

This commit is contained in:
Walter Bright 2022-09-27 05:42:35 -07:00 committed by GitHub
parent e5e181862b
commit 2f5f62287f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 1 deletions

View file

@ -0,0 +1,32 @@
/* DISABLED: win32 win64 linux32 osx32 osx64 freebsd32
*/
// https://issues.dlang.org/show_bug.cgi?id=23346
#pragma pack(pop) // do nothing
struct NotPacked1 {
int x;
long y;
};
#pragma pack(push, 4)
struct Packed {
int x;
long y;
};
#pragma pack(pop)
struct NotPacked {
int x;
long y;
};
int x[3] = {
sizeof(struct NotPacked1),
sizeof(struct Packed),
sizeof(struct NotPacked) };
_Static_assert(sizeof(struct NotPacked1) == 16, "1");
_Static_assert(sizeof(struct Packed) == 12, "2");
_Static_assert(sizeof(struct NotPacked ) == 16, "3");