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
Comment #1 by bugzilla — 2022-04-05T07:54:59Z
Probably forgot to multiply by sizeof.
Comment #2 by duser — 2022-04-17T22:29:45Z
Created attachment 1846
fix
attaching my patch i've been using that fixes this
Comment #3 by dlang-bot — 2022-04-18T05:21:20Z
@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
Comment #4 by dlang-bot — 2022-04-18T06:19:43Z
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