Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix buggy rand(RandomDevice(), Bool) #35590

Merged
merged 1 commit into from
Apr 27, 2020
Merged

Conversation

rfourquet
Copy link
Member

The tests might seem overkill for this particular bug, but I was writing them for #33721, so they will still be useful.

An alternative fix might be to define read(s::IO, ::Type{Bool}) = read(s, UInt8) % Bool instead of read(s, UInt8) != 0.
Both definitions coincide if Bools are stored in "canonical binary representation", and the definition of read seems to leave the result unspecified for non-canonical Bool.

@rfourquet rfourquet added randomness Random number generation and the Random stdlib embarrassing-bugfix Whoops! backport 1.0 labels Apr 24, 2020
@rfourquet rfourquet added this to the 1.5 milestone Apr 24, 2020
@JeffBezanson JeffBezanson merged commit 0bab06f into master Apr 27, 2020
@JeffBezanson JeffBezanson deleted the rf/fix-randomdevice-bool branch April 27, 2020 22:55
mbauman added a commit that referenced this pull request Apr 28, 2020
* origin/master: (833 commits)
  Improve typesubtract for tuples (#35600)
  Make searchsorted*/findnext/findprev return values of keytype (#32978)
  fix buggy rand(RandomDevice(), Bool) (#35590)
  remove `Ref` allocation on task switch (#35606)
  Revert "partr: fix multiqueue resorting stability" (#35589)
  exclude types with free variables from `type_morespecific` (#35555)
  fix small typo in NEWS.md (#35611)
  enable inline allocation of structs with pointers (#34126)
  SparseArrays: Speed up right-division by diagonal matrices (#35533)
  Allow hashing 1D OffsetArrays
  NEWS item for introspection macros (#35594)
  Special case empty covec-diagonal-vec product (#35557)
  [GCChecker] fix a few tests by looking through casts
  Use norm instead of abs in generic lu factorization (#34575)
  [GCChecker,NFC] run clang-format -style=llvm
  [GCChecker] fix tests and add Makefile
  Add introspection macros support for dot syntax (#35522)
  Specialize `union` for `OneTo` (#35577)
  add pop!(vector, idx, [default]) (#35513)
  bump Pkg version (#35584)
  ...
KristofferC pushed a commit that referenced this pull request May 10, 2020
@KristofferC KristofferC mentioned this pull request May 10, 2020
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embarrassing-bugfix Whoops! randomness Random number generation and the Random stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants