[GHC] #9035: ghci sometimes displays Word32 as Word64

GHC ghc-devs at haskell.org
Thu Apr 24 20:36:09 UTC 2014


#9035: ghci sometimes displays Word32 as Word64
------------------------------------------------+--------------------------
        Reporter:  MikeIzbicki                  |            Owner:
            Type:  bug                          |           Status:  new
        Priority:  normal                       |        Milestone:
       Component:  GHCi                         |          Version:  7.8.2
      Resolution:                               |         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 hvr):

 Replying to [ticket:9035 MikeIzbicki]:
 > For some reason, ghci is displaying (nanFloat+1) as having significantly
 more digits than can possibly stored in a Word32 value.

 Part of the reason is, that `Word32` is actually implemented as

 {{{#!haskell
 data Word32 = W32# Word# deriving (Eq, Ord)
 }}}

 and `Word#` is actually 64bit wide on the `x86_64` platform. So, `Word32`
 internally //can// actually store more digits than a 32-bit unsigned
 integer is supposed to hold. What I can't explain, though, is why a
 single-precision float, which should be 32bit wide, leaks into the hidden
 unused upper 32bit part of the `Float` (and thus also into the unsafely
 coerced `Word32`) heap object.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9035#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list