#1910: Native Code gen miscompiles double2Int# / float2Int# on x86_32
----------------------------+-----------------------------------------------
Reporter: int-e | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 6.8.2
Component: Compiler | Version: 6.8.1
Severity: normal | Keywords:
Difficulty: Easy (1 hr) | Testcase:
Architecture: x86 | Os: Unknown
----------------------------+-----------------------------------------------
''Brad Clow'':
I upgraded from GHC 6.6.1 to 6.8.1 and around that time I noticed that
the output from an app I am working on changed. I have distilled the
code down to the following example that produces different output
depending on whether it is compiled with -O2 or not:
{{{
main = do
let (T x) = read "T 3"
print $ f x
print $ g x
data T = T Int deriving (Read, Show)
f x = truncate $ 2000 / fromIntegral ((x * 25) + 10)
g :: Int -> Int
g x = f x
}}}
(See http://www.haskell.org/pipermail/haskell-
cafe/2007-November/034930.html)
The reason is that the code generated for {{{double2Int#}}} by the native
code generator does not round correctly. (It's not 100% predictable, I
believe, but it'll usually round.)
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1910>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs