Commit 74ee1237 authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

Bignum: fix bigNatCompareWord# bug (#18813)

parent 22f218b7
Pipeline #26096 failed
......@@ -339,7 +339,7 @@ bigNatCompareWord# a b
| bigNatIsZero a = cmpW# 0## b
| isTrue# (wordArraySize# a ># 1#) = GT
| True
= cmpW# (indexWordArray# a 1#) b
= cmpW# (indexWordArray# a 0#) b
-- | Compare a BigNat and a Word
bigNatCompareWord :: BigNat# -> Word -> Ordering
......
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -O0 #-}
import GHC.Exts
import GHC.Num.BigNat (bigNatCompareWord#, bigNatFromWord#)
import GHC.Num.Integer (integerGcd)
main :: IO ()
main = do
let
x = noinline (14205695611797621937 :: Integer)
y = noinline (2 :: Word)
print (integerGcd x (toInteger y))
print (toInteger (gcd (fromInteger x) y :: Word))
let
x@(W# x#) = 1 :: Word
!x' = bigNatFromWord# x#
print (bigNatCompareWord# x' x#)
print (compare x x)
......@@ -11,6 +11,7 @@ test('integerPowMod', [], compile_and_run, [''])
test('integerGcdExt', [], compile_and_run, [''])
test('integerRecipMod', [], compile_and_run, [''])
test('bignumMatch', [], compile, [''])
test('T18813', [], compile_and_run, [''])
# skip ghci as it doesn't support unboxed tuples
test('integerImportExport', [omit_ways(['ghci'])], compile_and_run, [''])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment