[Haskell-cafe] Re: -O2 bug in GHC 6.8.1?
Christian Maeder
Christian.Maeder at dfki.de
Tue Nov 20 08:26:01 EST 2007
good bug! -O or -O2 is irrelevant but it works if compiled with -fvia-C
You (or someone else) should add it to
http://hackage.haskell.org/trac/ghc
Christian
Brad Clow wrote:
> 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
>
> Here is the transcript from a shell (example code is saved in test.hs):
>
> $ ghc --make test.hs
> [1 of 1] Compiling Main ( test.hs, test.o )
> Linking test ...
> $ ./test
> 23
> 23
> $ rm test.hi test.o test
> $ ghc -O2 --make test.hs
> [1 of 1] Compiling Main ( test.hs, test.o )
> Linking test ...
> $ ./test
> 23
> 24
>
> It is a little disconcerting that -O2 changes the output. :-)
>
> Regards
> brad
>
More information about the Haskell-Cafe
mailing list