Unexpected behavior of unsafeCoerce converting Word32 to Word8
The function unsafeCoerce
behaves unexpected if it is used to convert Word32
to Word8
:
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.
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |