Hi Byron,
A little investigation revealed the following behaviour:
|size| < 10000 : runs fine
10000 <= |size| < 2^31-1 : runs out of heap
2^31-1 <= |size| : bug occurs
It seems that we're using signed arithmetic to calculate the size of the
array - and losing big time when the size >= maxint.
Sorry I don't have a patch at the moment. If you feel like fixing it
yourself, aNewSet in array.c seems to be the guilty party.
Alastair
ps You really ought to upgrade to a more recent version of Hugs.
It won't fix this bug but it'll save you from some of the others
we've fixed. (This applies to anyone who's pushing Hugs hard enough
that they're hitting new bugs on a regular basis.)
> I'm using Hugs-1.4 (version 970410) on the following machines:
> SunOS 5.5.x Ultra-1
> SunOS 4.1.x sun4c
> Linux 2.0.x i586
>
> (NOTE: this bug shows up in Hugs-1.3Beta too)
>
> The following function should return "3" when applied to both "True"
> and "False", but instead maps "True" to "2", and "False" to "3"
>
> bug :: Bool -> Int
> bug max = runST (
> do { array <- newArray size 0
> ; writeArray array 3 3
> ; writeArray array 2 2
> ; readArray array 3
> }
> )
> where
> size = if max
> then (minBound,maxBound) -- a BIG array
> else (0,20) -- a normal sized array