Passes in DMD compiler, but breaks in GDC during assert tests.

B4S1L3 suggested it might be an old compiler bug. I need confirmation if this is an old (not yet caught up) or a new one (to which I'll have to write or have a work-around until the bug is fixed).

// http://dpaste.com/0M7M8NK
uint[] sub(uint[] lhs, const (uint)[] rhs) {
    long t;    //temporary, doubles as carry

    foreach(i, ref v; lhs) {
        t += v;
        t -= rhs[i];
        v = cast(uint) t;
        //reset carry
        t >>= uint.sizeof*8;
    }

    return lhs;
}

unittest {
    uint[3] lhs = [99, 201, 300],
            rhs = [-1, 0, 0];

    assert(sub(lhs, rhs) == [100, 200, 300]);
}

Reply via email to