Opened 11 years ago

Closed 10 years ago

Last modified 3 years ago

#867 closed bug (fixed)

Integer arithmetic gives the wrong answer on amd64/Linux

Reported by: igloo Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.4.1
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


On x86 I get:

Prelude> reverse $ take 10 $ reverse $ show $ sum [ x ^ x | x <- [1..1000] ]

which is correct, but on amd64/Linux I get:

Prelude> reverse $ take 10 $ reverse $ show $ sum [ x ^ x | x <- [1..1000] ]

Both ghci's above are 6.4.1, but I also see it with the HEAD (a few days old).

Seen on Debian, Gentoo and rpath distributions.

Thanks Ian

Change History (3)

comment:1 Changed 11 years ago by duncan

I get the same results with ghc-6.4.2 and ghc-6.5.20060724 on my amd64 box.

It's fine in hugs on the amd64 and fine with ghc-6.4.2 on my sparc box. On both boxes I'm using gmp-4.1.4 (gentoo revision 3).

comment:2 Changed 10 years ago by igloo

Resolution: fixed
Status: newclosed

Fixed by:

Thu Sep 28 01:48:06 BST 2006  Ian Lynagh <>
  * Fix mulIntMayOflo on 64-bit arches; fixes trac #867
  We were assuming we could multiply 2 32-bit numbers without overflowing
  a 64-bit number, but we can't as the top bit is the sign bit.

Test is arith019.

comment:3 Changed 3 years ago by Ian Lynagh <igloo@…>

In 52eb09cc2e96f62143436958e493b37d43292f84/ghc:

Add a test for trac #867
Note: See TracTickets for help on using tickets.