www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12589] New: std.random.randomCover fails for empty ranges


          Issue ID: 12589
           Summary: std.random.randomCover fails for empty ranges
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: jens.k.mueller gmx.de

The following code fails (the second assert does not hold).

    import std.random;                                                          
    int[] r = [];                                                               
    auto gen = Random(0);                                                       
    auto c = randomCover(r, gen);                                               
    assert(c.length == 0);                                                      

Since empty is false calling front is valid which leads to disaster.

I used DMD64 D Compiler v2.065 on Linux.

Apr 16 2014