unsafeCoerce leaks types
Forgive the cryptic summary, here's the code:
import Unsafe.Coerce import Foreign import Data.Bits foo = (unsafeCoerce (0.50094324::Float))::Int32 bar = (unsafeCoerce (0.30295494::Float))::Int32 main = print (foo, foo .&. 0xffffffff) >> print (bar, bar .&. 0xffffffff)
giving the output
% runhaskell bug.hs (1056980433,1056980433) (140502315506921,140502315506921)
*Main> :t bar bar :: Int32 *Main> bar 140549560147177
where the too-big number changes from run to run, presumably because it has a different type-tag on each invocation. It does seem to include the correct data in the low 32 bits, though.
I couldn't replicate this with compiled code, but both GHCi and TH exhibit this behaviour.