[GHC] #9013: addWord2# is buggy

GHC ghc-devs at haskell.org
Sun Apr 20 03:22:38 UTC 2014


#9013: addWord2# is buggy
------------------------------------+-------------------------------------
       Reporter:  pumpkin           |             Owner:
           Type:  bug               |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  Compiler          |           Version:  7.8.2
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:                    |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 Looks like its behavior differs between optimization levels:

 {{{#!haskell
 {-# LANGUAGE MagicHash, UnboxedTuples #-}

 import GHC.Prim
 import GHC.Word

 big :: Word
 big = maxBound

 good = let x = case big of W# w -> w in case plusWord2# x x of (# a, b #)
 -> (W# a, W# b)

 main = do
   putStrLn $ case good of
     (0, z) -> "Such optimal, much sad"
     (1, z) -> "No optimization here"
 }}}

 I thought I was going crazy! Try the above code with and without -O2 and
 you'll get different output.

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


More information about the ghc-tickets mailing list