mozilla/rust — Issue #1689: bounds check error with vec::reserve 2 dimensional vectors
Author: 0x10
Created: 2012-01-27 21:57:51+00:00
State: open

The below code produces a runtime fail when calling vec::reserve within the while loop:
exact error:
rust: upcall fail 'bounds check', arraytest.rs:12
rust: domain main @0x13dcfb0 root task failed

type t_arrayarray = {
mutable arrayarray: [mutable [mutable u16]]
};

fn main(args: [str]) {
let myArrArr: t_arrayarray = {mutable arrayarray: [mutable [mutable]]};
vec::reserve(myArrArr.arrayarray, 10 as uint);
let i = 0u16;
while (i < 10u16)
{
vec::reserve(myArrArr.arrayarray[i], 3 as uint);
i+=1u16;
}
let j = 0u16;
i = 0u16;
while(i<10u16)
{
while( j < 3u16)
{
myArrArr.arrayarray[i][j] = i+j;
j+=1u16;
}
i+=1u16;
}

}