[GHC] #9035: ghci sometimes displays Word32 as Word64
GHC
ghc-devs at haskell.org
Mon May 19 02:51:02 UTC 2014
#9035: ghci sometimes displays Word32 as Word64
------------------------------------------------+--------------------------
Reporter: MikeIzbicki | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: GHCi | Version: 7.8.2
Resolution: invalid | Keywords:
Operating System: Linux | Architecture: x86_64
Type of failure: Incorrect result at runtime | (amd64)
Test Case: | Difficulty:
Blocking: | Unknown
| Blocked By:
| Related Tickets:
------------------------------------------------+--------------------------
Comment (by MikeIzbicki):
Replying to [comment:2 igloo]:
> This use of `unsafeCoerce` is not safe: See
[http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.7.0.0
/Unsafe-Coerce.html this] which links to
[http://www.haskell.org/ghc/docs/latest/html/libraries/ghc-prim-0.3.1.0
/GHC-Prim.html#v:unsafeCoerce-35- here] for more details.
I don't understand why it is incorrect. Is it because the float is boxed?
We can easily change the code to:
{{{
float2word32 :: Float -> Word32
float2word32 (F# f#) = W32# (unsafeCoerce# f#)
}}}
Now, we are casting between two unboxed types of the same size, which is
explicitly allowed. The results, however, are exactly the same as before.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9035#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list