[GHC] #10517: Unexpected behavior of unsafeCoerce converting Word32 to Word8

#10517: Unexpected behavior of unsafeCoerce converting Word32 to Word8 -------------------------------------+------------------------------------- Reporter: svenk | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Keywords: | Operating System: Linux Architecture: x86_64 | Type of failure: Incorrect result (amd64) | at runtime Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- The function `unsafeCoerce` behaves unexpected if it is used to convert `Word32` to `Word8`: {{{#!hs main = do -- prints 135 print (fromIntegral (1234567 :: Word32) :: Word8) -- prints 1234567 print (unsafeCoerce (1234567 :: Word32) :: Word8) }}} On the other hand coercing `Ptr Word32` to `Ptr Word8` or the other way around works perfectly fine. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10517 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10517: Unexpected behavior of unsafeCoerce converting Word32 to Word8 -------------------------------------+------------------------------------- Reporter: svenk | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: invalid | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result | (amd64) at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by ezyang): * status: new => closed * resolution: => invalid Comment: GHC gives no guarantees for this case: http://hackage.haskell.org/package /ghc-prim-0.3.1.0/docs/GHC-Prim.html#v:unsafeCoerce-35- since Word32 and Word8 are boxed types. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10517#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC