itos :: Int# -> String -> String
itos n# cs
- | n# <# 0# = let
- n'# = negateInt# n#
- in if n'# <# 0# -- minInt?
- then '-' : itos' (negateInt# (n'# `quotInt#` 10#))
- (itos' (negateInt# (n'# `remInt#` 10#)) cs)
- else '-' : 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
# ESSENTIAL, for getting reasonable performance from the I/O library:
SRC_HC_OPTS += -funbox-strict-fields
-# Grrr, gcc-4.1.0 has a bug in -O2 and higher that causes miscompilation of
-# GHC.Show.itos. See gcc bug #26824. We must drop back to -O1.
-GHC/Show_HC_OPTS += -optc-O1
-
# -----------------------------------------------------------------------------
# PrimOpWrappers