digitalmars.D.bugs - [Issue 22976] New: importC: address-of with struct pointer and array
- d-bugmail puremagic.com (30/30) Apr 02 2022 https://issues.dlang.org/show_bug.cgi?id=22976
https://issues.dlang.org/show_bug.cgi?id=22976 Issue ID: 22976 Summary: importC: address-of with struct pointer and array member gives wrong result 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: duser neet.fi CC: duser neet.fi struct S { unsigned short xs[2]; }; struct S s1 = { { 0xabcd, 0x1234 } }; struct S *sp = &s1; int printf(char *, ...); int main() { unsigned short *xp = &sp->xs[1]; printf("%hx\n", *xp); // 34ab unsigned short x = sp->xs[1]; printf("%hx\n", x); // 1234 return 0; } introduced in https://github.com/dlang/dmd/pull/13925 --
Apr 02 2022