Ticket #4143: SetBug.hs

File SetBug.hs, 350 bytes (added by japple, 3 years ago)

An Int overflow bug in Set for large, but not too close to maxBound-sized sets

Line 
1module SetBug where
2
3import qualified SetLocalInt16 as S
4import Data.Int
5
6big :: Int16
7big = maxBound
8
9almostBig :: Int16
10almostBig = (big `div` 2 + 1) {-`div` 2-}
11
12almostBigSet = S.fromDistinctAscList [1..almostBig]
13smallSet = S.fromDistinctAscList [almostBig+1,almostBig+2]
14violation = S.union smallSet almostBigSet
15
16main = print $ S.size violation