[Haskell-cafe] Error in array index.

Ketil Malde ketil at malde.org
Wed Jun 24 09:50:51 EDT 2009


Bulat Ziganshin <bulat.ziganshin at gmail.com> writes:

>>     array ((0,0),(65535,65535)) [((0,0),*** Exception: Error in array index

> i think that it may be a bit too large for internal Int indicies:

Aren't you asking for a 4G element array here, so with a 32bit
wraparound the array will be some multiple of 4GB, and be truncated
(silently, of course) down to zero, as per Int(32) behavior.  So in
effect, you have a zero-length underlying array, but the array
implementation still keeps track of the real indices and tries to
print some contents.  (Correct?)

See also:
  http://hackage.haskell.org/trac/ghc/ticket/2120

Since array dereferencing are now checked against the underlying array
instead of the real indices, you get this kind of inconsistency.  It
is greatly surprising to me that this has not been fixed.

As long as 'unsafeAt' gives you the speed without the safety, I don't
think the default dereferencing shouldn't sacrifice helpful error
messages and predicability.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list