www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21384] New: std.random.uniform!T() and

https://issues.dlang.org/show_bug.cgi?id=21384

          Issue ID: 21384
           Summary: std.random.uniform!T() and std.random.uniform!T(urng)
                    when T is dchar with any qualifiers can exceed
                    dchar.max
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com

std.random.uniform!T() and std.random.uniform!T(urng) when T is dchar with any
qualifiers can exceed dchar.max

Demonstration:
---
void main()
{
    import std.random : uniform, Xorshift32;

    auto rng = Xorshift32(123456789);
    const result = uniform!(const dchar)(rng);
    assert(result <= dchar.max); // Fails.
}
---

--
Nov 12 2020