[GHC] #9533: Signed/unsigned integer difference between compiled and interpreted code

GHC ghc-devs at haskell.org
Sun Aug 31 16:22:39 UTC 2014


#9533: Signed/unsigned integer difference between compiled and interpreted code
-------------------------------------+-------------------------------------
              Reporter:              |            Owner:
  MichaelBurge                       |           Status:  new
                  Type:  bug         |        Milestone:
              Priority:  high        |          Version:  7.8.3
             Component:  Compiler    |         Keywords:
            Resolution:              |     Architecture:  x86_64 (amd64)
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:
       Type of failure:  Incorrect   |  Related Tickets:
  result at runtime                  |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 It's not specific to `Word#` actually. The following program has the same
 wrong behavior.
 {{{
 x :: Int
 x = 11

 y :: Int
 y = 10

 test = case x - y of
          3 -> "D"  -- comment out either of these two lines and output
 will be "A"
          5 -> "C"
          18446744073709551617 -> "A" -- 2^64 + 1
          _  -> "B"
 main = putStrLn $ show test
 }}}

 If I build ghc with `-DDEBUG` I get panics like
 {{{
 ghc-stage2: panic! (the 'impossible' happened)
   (GHC version 7.9.20140831 for x86_64-unknown-linux):
         ASSERT failed!
     file compiler/basicTypes/Literal.lhs line 222 18446744073709551617
 }}}
 so I suppose the error is really in creating these `Literal`s with out-of-
 range values.

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


More information about the ghc-tickets mailing list