patch applied (packages/array): Improve the index checking for array accesses; fixes #2120 #2669

Simon Marlow marlowsd at gmail.com
Fri Jul 24 04:53:28 EDT 2009


On 24/07/2009 00:16, Ian Lynagh wrote:
> 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

That's bad, isn't it?  Can we fix it with some specialisation?

Cheers,
	Simon


More information about the Cvs-libraries mailing list