Re: Simple IDL array bound checking bug [message #7019] |
Fri, 13 September 1996 00:00 |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
William Connolley wrote:
> How on earth doees IDL fail to spot the following array bound violation?
> wmc> data=fltarr(1)
> ; Case 1 - OK
> wmc> print,data(2)
> % Attempt to subscript DATA with <INT ( 2)> is out of range.
> % Execution halted at: $MAIN$
> ; Case 2 - blithely prints junk
> wmc> print,data([2])
> 0.00000
This is explained on page 5-5 of the IDL 4.0.1 User's Guide,
"Array Subscripts". I quote:
"If an element of the subscript array is less than or equal to zero, the
first element of the subscripted variable is selected. If an element of
the subscript is greater than or equal to the last subscript in the
subscripted variable (N, above), the last element is selected. "
Cheers,
Liam.
|
|
|