#1989: GHC-6.8.1 fails arith003 on amd64/FreeBSD-7.0
----------------------+-----------------------------------------------------
Reporter: wb.kloke | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 6.8.3
Component: Compiler | Version: 6.8.2
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Architecture: x86_64 (amd64)
Os: FreeBSD |
----------------------+-----------------------------------------------------
Changes (by igloo):
* milestone: => 6.8.3
Comment:
If you've built stage3 then that means the compiler itself is now
basically working, right?
For arith003, the maths looks OK, I assume the problem is with the
printing code:
{{{
showSignedInt :: Int -> Int -> ShowS
showSignedInt (I# p) (I# n) r
| n <# 0# && p ># 6# = '(' : itos n (')' : r)
| otherwise = itos n r
itos :: Int# -> String -> String
itos n# cs
| n# <# 0# =
let I# minInt# = minInt in
if n# ==# minInt#
-- negateInt# minInt overflows, so we can't do that:
then '-' : itos' (negateInt# (n# `quotInt#` 10#))
(itos' (negateInt# (n# `remInt#` 10#)) cs)
else '-' : itos' (negateInt# n#) cs
| otherwise = itos' n# cs
where
itos' :: Int# -> String -> String
itos' n# cs
| n# <# 10# = C# (chr# (ord# '0'# +# n#)) : cs
| otherwise = case chr# (ord# '0'# +# (n# `remInt#` 10#)) of { c#
->
itos' (n# `quotInt#` 10#) (C# c# : cs) }
}}}
My suspicion is that the sign of one or both of these will be wrong:
{{{
Prelude> :set -fglasgow-exts
Prelude> :m + GHC.Exts
Prelude GHC.Exts> I# ((-9223372036854775808#) `remInt#` 10#)
-8
Prelude GHC.Exts> I# ((-9223372036854775808#) `quotInt#` 10#)
-922337203685477580
}}}
Otherwise, reproducing the problem with the printing code in a module of
its own, using `showSignedInt 0 minBound ""` (you'll need to import
GHC.Exts, and possibly other modules, and the problem may be sensitive to
commandline flags like `-fvia-C/-fasm`, `-O0/-O/-O2`) and then cutting it
down to work out exactly which step gives the wrong answer may point in
the direction of the problem.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1989#comment:3>
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