D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21609 - LinearCongruentialEngine fails for m = 0
Summary: LinearCongruentialEngine fails for m = 0
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2021-02-04 04:25 UTC by elpenguino+D
Modified: 2021-02-05 01:37 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description elpenguino+D 2021-02-04 04:25:20 UTC
std.random.LinearCongruentialEngine has an undocumented behaviour that allows for m = 0 when UIntType == uint, treating it as if it were 2^32. This special case is untested, and currently (as of DMD 2.095) produces a division by zero error.

example:
```
alias MSVC = LinearCongruentialEngine!(uint, 214013, 2531011, 0);
```
Comment 1 Dlang Bot 2021-02-04 04:27:53 UTC
@Herringway created dlang/phobos pull request #7786 "Fix issue 21609 - LinearCongruentialEngine fails for m = 0" fixing this issue:

- Fix issue 21609 - LinearCongruentialEngine fails for m = 0

https://github.com/dlang/phobos/pull/7786
Comment 2 Dlang Bot 2021-02-05 01:37:30 UTC
dlang/phobos pull request #7786 "Fix issue 21609 - LinearCongruentialEngine fails for m = 0" was merged into master:

- 883fd4fad26e39f79084581ae401b9d9e37583e0 by Cameron Ross:
  Fix issue 21609 - LinearCongruentialEngine fails for m = 0

https://github.com/dlang/phobos/pull/7786