[GHC] #921: Floating point with -O and -fasm is broken
GHC
trac at galois.com
Tue Oct 3 23:39:10 EDT 2006
#921: Floating point with -O and -fasm is broken
-------------------------------+--------------------------------------------
Reporter: guest | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (NCG) | Version: 6.4.1
Severity: normal | Keywords:
Os: Linux | Difficulty: Unknown
Architecture: x86_64 (amd64) |
-------------------------------+--------------------------------------------
I have some simple floating-point code that fails badly when you compile
it with -O and -fasm on x86_64. Here is the program:
log2 x = ceiling log_x
where log_x :: Double
log_x = logBase 2 (fromIntegral (max 1 x))
vals = [1, 2, 17, 259, 1000, 10000,
2^30 + 9000, 2^31 - 1, 2^31, 2^31 + 1,
2^32 - 1, 2^32, 2^32 + 1]
main :: IO ()
main = putStrLn (show (map log2 vals))
The result should be: [0,1,5,9,10,14,31,31,32,32,32,32,33]
With -O and -fasm on x86_64 the last five values are corrupted (four very
large numbers I'm not going to paste here, followed by 0).
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/921>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list