[Issue 22976] New: importC: address-of with struct pointer and array member gives wrong result

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 3 05:27:14 UTC 2022


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 at puremagic.com
          Reporter: duser at neet.fi
                CC: duser at 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

--


More information about the Digitalmars-d-bugs mailing list