unsafeCoerce# between integral and floating point types

Daniel Fischer daniel.is.fischer at web.de
Thu Jul 8 12:56:50 EDT 2010


On Thursday 08 July 2010 18:15:44, Ian Lynagh wrote:
> On Thu, Jul 08, 2010 at 04:49:00PM +0200, Daniel Fischer wrote:
> > unsafeCoerce# :: Word64# -> Double# ?
> >
> > By the docs, that isn't supposed to work. Is it not supposed to work
> > only because it's not value-preserving (unsafeCoerce# 1## /=## 1.0##)
> > or are there more pitfalls?
>
> It can fail to compile, even; see
> http://hackage.haskell.org/trac/ghc/ticket/2209
>

Yeah, tried that myself, with optimisations:

[2 of 2] Compiling Main             ( testUCastD.hs, testUCastD.o )                     
ghc: panic! (the 'impossible' happened)                                                 
  (GHC version 6.12.3 for i386-unknown-linux):                                          
        getRegister(x86) I64[R1 + 3]                                                    

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

But without optimisations, it compiles and seems to work (I won't rely on 
that, was just curious).

Should I report it or is the panic okay since unsafeCoerce# isn't supposed 
to work for those types?



More information about the Glasgow-haskell-users mailing list