Bug 12826 – Win64: bad code for x ~= x;

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2014-05-31T12:08:00Z
Last change time
2014-06-03T00:09:46Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
r.sagitario

Comments

Comment #0 by r.sagitario — 2014-05-31T12:08:52Z
This code: void main() { string s, t; t = t ~ "1234567"; s = s ~ "1234567"; s ~= s; assert(s == "12345671234567", s); assert(t == "1234567", t); } asserts when compiled for Win64 because "s ~= s;" overwrites t. This happens because _d_arrayappendT(const TypeInfo ti, ref byte[] x, byte[] y) is called with both parameters passed by ref according to the ABI, but no copy is made for y.
Comment #1 by r.sagitario — 2014-05-31T12:22:36Z
Comment #2 by github-bugzilla — 2014-06-01T03:59:42Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c7051cd1a109c12b3472e1b00f028b3dc0852612 Merge pull request #3608 from rainers/issue12826 fix 12826: make a copy of the second argument to _d_arrayappendT to avoid aliasing