[Issue 13073] Wrong uint array comparison

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jul 8 07:10:21 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13073

Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|rejects-valid               |wrong-code
          Component|DMD                         |druntime
           Hardware|x86                         |All
                 OS|Windows                     |All

--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> ---
This is druntime issue.

>From druntime/src/rt/typeinfo/ti_Aint.d

class TypeInfo_Ak : TypeInfo_Ai
{
    override string toString() const { return "uint[]"; }

    override int compare(in void* p1, in void* p2) const
    {
        uint[] s1 = *cast(uint[]*)p1;
        uint[] s2 = *cast(uint[]*)p2;
        size_t len = s1.length;

        if (s2.length < len)
            len = s2.length;
        for (size_t u = 0; u < len; u++)
        {
            int result = s1[u] - s2[u];    // <----
            if (result)
                return result;
        }
        if (s1.length < s2.length)
            return -1;
        else if (s1.length > s2.length)
            return 1;
        return 0;
    }

    override @property inout(TypeInfo) next() inout
    {
        return cast(inout)typeid(uint);
    }
}

--


More information about the Digitalmars-d-bugs mailing list