Simon Marlow wrote:
>
> I'm having lots of hassle with (minBound :: Int) in GHC right now, and since
> I'm such a kind chap I thought I'd share the grief with you guys. Here's a
> nice bug report:
>
> Hugs 98, Nov1999, i386-unknown-linux:
>
> Prelude> fromIntegral (minBound :: Int) :: Int
>
> Program error: {primIntegerToInt (-2147483648)}
>
> Cheers,
> Simon
Thanks Simon.
The code that converts Integer to Int internally barfs on
minBound. This is the only int it barfs on.
However, this problem does not happen in STG Hugs98.
If you really need to fix this in Classic Hugs 98 (November 1999)
release, you can edit Prelude.hs to add a wrapper round
primIntegerToInt, checking for minBound and returning the
correct value.
Perhaps we should develop a testing framework to check
for corner cases like this, catching them before a release.
Andy
--
Andy Gill
Principal Project Scientist, Pacific Software Research Center
Department of Computer Science and Engineering
Oregon Graduate Institute of Science & Technology
phone +1 503 748 7451 http://www.cse.ogi.edu/~andy