Bug 12589 – std.random.randomCover fails for empty ranges
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-04-16T15:15:00Z
Last change time
2015-02-18T03:40:34Z
Assigned to
nobody
Creator
jens.k.mueller
Comments
Comment #0 by jens.k.mueller — 2014-04-16T15:15:03Z
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.
Comment #1 by github-bugzilla — 2014-12-06T18:42:58Z