Bug 17847 – Properly sanitize seeds for Park–Miller engines

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-09-21T18:16:35Z
Last change time
2017-10-16T09:58:06Z
Assigned to
No Owner
Creator
Nathan S.

Comments

Comment #0 by natesash — 2017-09-21T18:16:35Z
The current check is broken because it checks the seed before taking the modulus. Additionally, as in XorshiftEngine, sanitizing the seed would be more useful than throwing an exception.
Comment #1 by natesash — 2017-09-21T18:19:11Z
Comment #2 by github-bugzilla — 2017-09-25T13:31:13Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/fd2e5ba03c2c1304dd516a32e2659c3ed01c1936 Fix Issue 17847 - Properly sanitize seeds for Park–Miller engines As in XorshiftEngine, sanitizing the seed is more useful than throwing an exception. The original check was broken because it checked the seed before taking the modulus. Making this change allows unpredictableSeed to be marked nothrow and @nogc. https://github.com/dlang/phobos/commit/218434f4b72bd4b8616214a615fe8cd433c6efe0 Merge pull request #5743 from n8sh/fix-random-lcg Fix Issue 17847 - Properly sanitize seeds for Park–Miller engines merged-on-behalf-of: Dmitry Olshansky <[email protected]>
Comment #3 by github-bugzilla — 2017-10-16T09:58:06Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/fd2e5ba03c2c1304dd516a32e2659c3ed01c1936 Fix Issue 17847 - Properly sanitize seeds for Park–Miller engines https://github.com/dlang/phobos/commit/218434f4b72bd4b8616214a615fe8cd433c6efe0 Merge pull request #5743 from n8sh/fix-random-lcg