digitalmars.D.bugs - [Issue 23427] New: ImportC: some bitfield combinations lead to wrong
- d-bugmail puremagic.com (37/37) Oct 19 2022 https://issues.dlang.org/show_bug.cgi?id=23427
https://issues.dlang.org/show_bug.cgi?id=23427 Issue ID: 23427 Summary: ImportC: some bitfield combinations lead to wrong size struct Product: D Version: D2 Hardware: All OS: Mac OS X Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: dave287091 gmail.com On macOS, the following C code compiles without failing a static assertion using apple clang. Dmd triggers the static assertion. I haven’t tested other platforms. _Static_assert(sizeof(unsigned) == 4, ""); struct A { unsigned x :8; unsigned y :4; unsigned z :20; }; _Static_assert(sizeof(struct A)==4, ""); struct B { unsigned x :4; unsigned y :2; unsigned z :26; }; _Static_assert(sizeof(struct B)==4, ""); struct C { unsigned x :4; unsigned y :4; unsigned z :24; }; _Static_assert(sizeof(struct C)==4, ""); // This one fails --
Oct 19 2022