Skip to content

Commit 7fb91ca

Browse files
Ericson2314treeowl
authored andcommitted
Fix for indexInt8OffAddr# returning sized type in next GHC
Here's how we fix this without CPP: In old GHC: I8# :: Int# -> Int8 indexInt8OffAddr# :: Addr# -> Int# -> Int# In upcoming GHC 9.2: I8# :: Int8# -> Int8 indexInt8OffAddr# :: Addr# -> Int# -> Int8# So the "GLB" interface is: exists alpha. I8# :: alpha -> Int8 indexInt8OffAddr# :: Addr# -> Int# -> alpha We we write a program against that, eliminating the black-box `alpha` with `I8#` and then converting to `Int`.
1 parent 9f65489 commit 7fb91ca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

containers/src/Data/IntSet/Internal.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ import Text.Read
221221

222222
#if __GLASGOW_HASKELL__
223223
import qualified GHC.Exts
224+
#if !(MIN_VERSION_base(4,8,0) && (WORD_SIZE_IN_BITS==64))
225+
import qualified GHC.Int
226+
#endif
224227
#endif
225228

226229
import qualified Data.Foldable as Foldable
@@ -1642,7 +1645,7 @@ highestBitSet x = WORD_SIZE_IN_BITS - 1 - countLeadingZeros x
16421645
----------------------------------------------------------------------}
16431646

16441647
indexOfTheOnlyBit bitmask =
1645-
GHC.Exts.I# (lsbArray `GHC.Exts.indexInt8OffAddr#` unboxInt (intFromNat ((bitmask * magic) `shiftRL` offset)))
1648+
fromIntegral (GHC.Int.I8# (lsbArray `GHC.Exts.indexInt8OffAddr#` unboxInt (intFromNat ((bitmask * magic) `shiftRL` offset))))
16461649
where unboxInt (GHC.Exts.I# i) = i
16471650
#if WORD_SIZE_IN_BITS==32
16481651
magic = 0x077CB531

0 commit comments

Comments
 (0)