Array operation doesn't check array bounds
Simon
s.d.hammett at gmail.com
Sun Apr 3 04:32:34 PDT 2011
On 03/04/2011 12:10, simendsjo wrote:
> int[] a = [1,2,3];
>
> int[4] b;
> assert(b == [0,0,0,0]);
> b = a[] * 3; // oops... a[] * 3 takes element outside a's bounds
> assert(b[$-1] == 0); // fails.. last element is *(a.ptr+3) * 3
From the D spec:
"A program may not rely on array bounds checking happening"
--
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
More information about the Digitalmars-d-learn
mailing list