Ticket #3561 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

Incorrect code generation on x86

Reported by: aleksey Owned by: simonmar
Priority: high Milestone: 6.12.1
Component: Compiler Version: 6.10.4
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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.

Change History

Changed 4 years ago by simonmar

  • priority changed from normal to high
  • difficulty set to Unknown
  • milestone set to 6.12.1

Changed 4 years ago by igloo

I can reproduce this with 6.10.1 but not 6.12.0.20091005, so it looks like it is already fixed.

Changed 4 years ago by dmp

I can also reproduce this with 6.10.4 but not 6.12.0.20091007 on mac os x 10.6.

Changed 4 years ago by simonmar

  • owner set to simonmar

Changed 4 years ago by simonmar

  • status changed from new to closed
  • resolution set to fixed

Test added.

Note: See TracTickets for help on using tickets.