www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12826] New: Win64: bad code for x ~= x;


          Issue ID: 12826
           Summary: Win64: bad code for x ~= x;
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: r.sagitario gmx.de

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.

May 31 2014