Incorrect code generation on x86
This program prints "0" on x86 with ghc-6.10.4 and "-O" optimization at least under Linux and FreeBSD:
main = print $ pqr' 0 1
pqr' :: Int -> Int -> Integer
pqr' a b | a == b - 1 = rab
| otherwise = ram * rmb
where m = (a + b) `div` 2
ram = pqr' a m
rmb = pqr' m b
rab = toInteger (6 * b - 5) * toInteger (2 * b - 1) *
toInteger (6 * b - 1)
It prints the correct value "5" with either "-O0", or "-fvia-C", or on x86_64.
Trac metadata
Trac field | Value |
---|---|
Version | 6.10.4 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |