patch applied (packages/array): Improve the index checking for
array accesses; fixes #2120 #2669
Ian Lynagh
igloo at earth.li
Thu Jul 23 19:16:13 EDT 2009
On Mon, Jul 20, 2009 at 09:07:14AM +0100, Simon Marlow wrote:
> On 19/07/2009 16:59, Ian Lynagh wrote:
>> Sun Jul 19 08:29:31 PDT 2009 Ian Lynagh<igloo at earth.li>
>> * Improve the index checking for array accesses; fixes #2120 #2669
>> As well as checking that offset we are reading is actually inside the
>> array, we now also check that it is "in range" as defined by the Ix
>> instance. This fixes confusing behaviour (#2120) and improves some error
>> messages (#2669).
>
> Does the extra test get optimised away in the common case?
No.
For example, for an Int-indexed array:
We call GHC.Arr.$fIxInt_$windex which does the
lowerBound <= index
index <= upperBound
tests, and returns (index - lowerBound).
Then there are inlined tests for
0 <= result
result < size
Thanks
Ian
More information about the Cvs-libraries
mailing list