On 04/03/2011 05:06 PM, Jonathan M Davis wrote:
On 2011-04-03 04: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
On 2011-04-03 04: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
Array bounds checking is done on cod
Simon:
> No it doesn't. D is supposed to be systems programming language.
> Unnecessary bounds checking would make array access too slow.
D has already array bounds, even to access single items. Array operations are
bulk, so they need only one bound test, then they perform many operations
witho
On 03/04/2011 12:39, simendsjo wrote:
On 03.04.2011 13:32, Simon wrote:
From the D spec:
"A program may not rely on array bounds checking happening"
Where in the spec are you finding this? Or are you talking in general,
not just on array operations?
D does bounds checking, so I don't see a
On 03/04/2011 12:46, bearophile wrote:
Simon:
"A program may not rely on array bounds checking happening"
Yet DMD has to perform them to help programmers.
No it doesn't. D is supposed to be systems programming language.
Unnecessary bounds checking would make array access too slow.
Mind you
Simon:
> "A program may not rely on array bounds checking happening"
Yet DMD has to perform them to help programmers. I think this bug report is
already in Bugzilla, but I'd like to be sure.
Bye,
bearophile
On 03.04.2011 13:32, Simon wrote:
From the D spec:
"A program may not rely on array bounds checking happening"
Where in the spec are you finding this? Or are you talking in general,
not just on array operations?
D does bounds checking, so I don't see a reason why it shouldn't do it
on ar
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 no
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