digitalmars.D.bugs - [Issue 12589] New: std.random.randomCover fails for empty ranges
- d-bugmail puremagic.com (26/26) Apr 16 2014 https://issues.dlang.org/show_bug.cgi?id=12589
https://issues.dlang.org/show_bug.cgi?id=12589 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). unittest { import std.random; int[] r = []; auto gen = Random(0); auto c = randomCover(r, gen); assert(c.length == 0); assert(c.empty); } Since empty is false calling front is valid which leads to disaster. I used DMD64 D Compiler v2.065 on Linux. --
Apr 16 2014