Opened 3 years ago

Closed 3 years ago

#4910 closed bug (fixed)

mkStdGen (-2^31) is ⊥

Reported by: ion1 Owned by:
Priority: high Milestone: 7.2.1
Component: libraries/random Version:
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Quoting System/Random?.hs:

mkStdGen32 :: Int32 -> StdGen
mkStdGen32 s
 | s < 0     = mkStdGen32 (-s)

Alas, the fact that…

ghci> (minBound :: Data.Int.Int32) == negate minBound
True

…results in mkStdGen32 going into infinite recursion when applied to the minBound of Int32.

The proposed patch should fix the issue.

Attachments (1)

mkStdGen32-avoid-infinite-recursion.dpatch (2.8 KB) - added by ion1 3 years ago.
mkStdGen32: Avoid infinite recursion when applied to minBound

Download all attachments as: .zip

Change History (4)

Changed 3 years ago by ion1

mkStdGen32: Avoid infinite recursion when applied to minBound

comment:1 Changed 3 years ago by ion1

  • Status changed from new to patch

comment:2 Changed 3 years ago by igloo

  • Milestone set to 7.0.3
  • Priority changed from normal to high

comment:3 Changed 3 years ago by igloo

  • Resolution set to fixed
  • Status changed from patch to closed

Applied, thanks!

Note: See TracTickets for help on using tickets.