Bug 18332 – rt.util.random.Rand48 remove unnecessary assert

Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-01-30T03:45:55Z
Last change time
2018-07-02T15:37:39Z
Assigned to
No Owner
Creator
Nathan S.

Comments

Comment #0 by n8sh.secondary — 2018-01-30T03:45:55Z
seed(uint): There is no need for seedval to be non-zero. The assertion should be removed. popFront(): rng_state is private and is only exposed through front() which never exposes the high 16 bits of rng_state. popFront() advances rng_state through addition and multiplication so the high 16 bits of the current rng_state never affect the low 48 bits of the next rng_state. So masking rng_state to clear the high 16 bits is unnecessary (unless comparing Rand48 structs for equality or computing bitwise hashcodes of their contents, which doesn't appear to happen anywhere).
Comment #1 by n8sh.secondary — 2018-01-30T03:49:39Z
Strike the comments about popFront(): the mask is necessary. >popFront() advances rng_state through addition and multiplication so the high 16 bits of the current rng_state never affect the low 48 bits of the next rng_state The "and addition" is why this statement is false.
Comment #2 by n8sh.secondary — 2018-01-30T03:52:22Z
Comment #3 by github-bugzilla — 2018-03-12T13:35:50Z
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/3d02a6e72533ee9399a7f2d40caa7c463f2f4020 Issue 18332 - rt.util.random.Rand48 remove unnecessary assert https://github.com/dlang/druntime/commit/01643aadf0c28be03ca64e6614fb592356a3d40e Merge pull request #2069 from n8sh/rand48 Issue 18332 - rt.util.random.Rand48 remove unnecessary assert
Comment #4 by n8sh.secondary — 2018-07-02T15:37:39Z
For some reason this didn't auto-close.