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
Probably forgot to multiply by sizeof.
Created attachment 1846 [details] fix attaching my patch i've been using that fixes this
@WalterBright created dlang/dmd pull request #14005 "fix Issue 22976 - importC: fails to multiply by element size when doi…" fixing this issue: - fix Issue 22976 - importC: fails to multiply by element size when doing address-of https://github.com/dlang/dmd/pull/14005
dlang/dmd pull request #14005 "fix Issue 22976 - importC: fails to multiply by element size when doi…" was merged into master: - 1f561d908198c96e62b899370d16f4b4588da05d by Walter Bright: fix Issue 22976 - importC: fails to multiply by element size when doing address-of https://github.com/dlang/dmd/pull/14005