www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18285] New: std.algorithm.comparison.cmp for strings with


          Issue ID: 18285
           Summary: std.algorithm.comparison.cmp for strings with custom
                    predicate erroneously compares lengths with pred
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com


Sample code demonstrating bug:
void main()
    import std.algorithm.comparison : cmp;
    // Note that "a > b" is the reverse of the normal.
    static assert(cmp!"a > b"("1", "2") > 0);
    // Following fails because cmp is using the predicate "a > b"    
    // to compare the lengths of the ranges.    
    static assert(cmp!"a > b"("abc", "abcd") < 0,
                 `Should be negative because "abc" is a prefix of "abcd"!`);

Jan 22 2018