diff --git a/src/dmd/backend/cod4.d b/src/dmd/backend/cod4.d index 69e7d6b30959..b143cddb485b 100644 --- a/src/dmd/backend/cod4.d +++ b/src/dmd/backend/cod4.d @@ -443,7 +443,7 @@ void cdeq(ref CodeBuilder cdb,elem *e,regm_t *pretregs) postinc = e11.EV.E2.EV.Vint; if (e11.Eoper == OPpostdec) postinc = -postinc; - getlvalue(cdb,&cs,e11,RMstore); + getlvalue(cdb,&cs,e1,RMstore); freenode(e11.EV.E2); } else @@ -710,10 +710,8 @@ void cdeq(ref CodeBuilder cdb,elem *e,regm_t *pretregs) postinc = e11.EV.E2.EV.Vint; if (e11.Eoper == OPpostdec) postinc = -postinc; - getlvalue(cdb,&cs,e11,RMstore | retregs); + getlvalue(cdb,&cs,e1,RMstore | retregs); freenode(e11.EV.E2); - if (I64 && sz < 8) - cs.Irex &= ~REX_W; // incorrectly set by getlvalue() } else { diff --git a/test/runnable/mars1.d b/test/runnable/mars1.d index b7cca5586a20..f4abe0043d12 100644 --- a/test/runnable/mars1.d +++ b/test/runnable/mars1.d @@ -1838,6 +1838,44 @@ void test18730() // https://issues.dlang.org/show_bug.cgi?id=18730 //////////////////////////////////////////////////////////////////////// +void test19497() // https://issues.dlang.org/show_bug.cgi?id=19497 +{ + { + ubyte[1024] data; + ushort* ushortPtr = cast(ushort*) data.ptr; + *ushortPtr++ = 0xfe00; + printf("ushortPtr(%p)\n", ushortPtr); + fflush(stdout); + } + + alias Seq(stuff ...) = stuff; + static foreach (T; Seq!(ubyte, ushort, uint, ulong, byte, short, int, long)) + {{ + T[2] data = 0x2A; + T* q = &data[0]; + *q++ = cast(T) 0x1122334455667788; + if (*q != 0x2A) assert(false); + }} + + { + static int toStringz(string s) { return s.length > 0 ? s[0] : 0; } + static void toAStringz(in string[] a, int* az) + { + foreach (string s; a) + { + *az++ = toStringz(s); + } + } + string[1] sa = ["abc"]; + int[2] tgt = 0x2a; + toAStringz(sa[], tgt.ptr); + if (tgt[0] != 'a') assert(false); + if (tgt[1] != 0x2a) assert(false); + } +} + +//////////////////////////////////////////////////////////////////////// + int main() { testgoto(); @@ -1903,6 +1941,7 @@ int main() test18315(); test18461(); test18730(); + test19497(); printf("Success\n"); return 0;