[Issue 3355] New: std.string.cmp works incorrectly for mixed-type and different-length strings

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 1 01:08:41 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3355

           Summary: std.string.cmp works incorrectly for mixed-type and
                    different-length strings
           Product: D
           Version: 2.032
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Keywords: patch
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: acehreli at yahoo.com


--- Comment #0 from Ali Cehreli <acehreli at yahoo.com> 2009-10-01 01:08:40 PDT ---
cmp fails unit tests when added this one

    result = cmp("aa", "aaa"d);
    assert(result < 0);


The patch is trivial:

109c109
<             if (i1 == s1.length) return s2.length - i2;
---
>             if (i1 == s1.length) return i2 - s2.length;
136a137,143
> 
>     result = cmp("aa", "aaa"d);
>     assert(result < 0);
>     result = cmp("aaa", "aa"d);
>     assert(result > 0);
>     result = cmp("aa", "aa"d);
>     assert(result == 0);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list