[Issue 12877] std.random.uniform cannot handle dchar variates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jun 10 05:14:40 PDT 2014


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

--- Comment #2 from github-bugzilla at puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/cb5ee35ad69024293d5d557151e5939065fa0a06
Fix Issue #12877: allow uniform() to handle dchar variates

Since [dchar.min, dchar.max] does not cover the full bit range of dchar,
optimizations that work for other integral types will fail here, and
result in illegal unicode points being generated.

This fix avoids breaking any existing calls to uniform() via a twofold
approach:

   * uniform!"[]"(T.min, T.max) will only call uniform!ResultType if
     T is not a dchar;

   * uniform!dchar will not try and use the entire bit range but will
     instead call uniform!"[]"(dchar.min, dchar.max).

Unittests have been added that should prevent such issues from arising
again.

https://github.com/D-Programming-Language/phobos/commit/240a11ebe31ca9980d951553c2dac3fd62070b56
Merge pull request #2235 from WebDrake/uniform-dchar

Fix Issue #12877: allow uniform() to handle dchar variates

--


More information about the Digitalmars-d-bugs mailing list