[GHC] #8726: integer-gmp division regression

GHC ghc-devs at haskell.org
Sun Feb 2 13:17:58 UTC 2014


#8726: integer-gmp division regression
------------------------------------------------+--------------------------
        Reporter:  erikd                        |            Owner:  hvr
            Type:  bug                          |           Status:  new
        Priority:  highest                      |        Milestone:  7.8.1
       Component:  libraries (other)            |          Version:
      Resolution:                               |  7.8.1-rc1
Operating System:  Unknown/Multiple             |         Keywords:
 Type of failure:  Incorrect result at runtime  |  Integer-gmp
       Test Case:                               |     Architecture:
        Blocking:                               |  Unknown/Multiple
                                                |       Difficulty:
                                                |  Unknown
                                                |       Blocked By:
                                                |  Related Tickets:
------------------------------------------------+--------------------------

Comment (by Herbert Valerio Riedel <hvr@…>):

 In [changeset:"2f841fdf5b33c4eb32cfc5d1b8207585f1880d9a/integer-gmp"]:
 {{{
 #!CommitTicketReference repository="integer-gmp"
 revision="2f841fdf5b33c4eb32cfc5d1b8207585f1880d9a"
 Fix negation of `divMod`/`quotRem` results (fixes #8726)

 High-level pseudo code of what the code was supposed to implement:

     quotRem' :: Integer -> Integer -> (Integer,Integer)
     quotRem' a b@(S# _)
       | b < 0     = negFst . uncurry quotRem' . negSnd $ (a,b)
       | otherwise = quotRemUI a (fromIntegral (abs b))

     divMod' :: Integer -> Integer -> (Integer,Integer)
     divMod' a b@(S# _)
       | b < 0      = negSnd . uncurry divMod' . negBoth $ (a,b)
       | otherwise  = divModUI a (fromIntegral b)

     negFst  (q,r) = (-q,r)
     negSnd  (q,r) = ( q,-r)
     negBoth (q,r) = (-q,-r)

     -- quotRemUI and divModUI represent GMP's `mpz_{f,t}div_qr_ui()`
     quotRemUI, divModUI :: Integer -> Word -> (Integer,Integer)

 Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8726#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list