rust/src/test/run-fail/vec-overrun.rs

12 lines
183 B
Rust
Raw Normal View History

2010-06-24 04:03:09 +00:00
// -*- rust -*-
// error-pattern:bounds check
2010-06-24 04:03:09 +00:00
fn main() {
let vec[int] v = [10];
2010-06-24 04:03:09 +00:00
let int x = 0;
assert (v.(x) == 10);
2010-06-24 04:03:09 +00:00
// Bounds-check failure.
assert (v.(x + 2) == 20);
2010-06-24 04:03:09 +00:00
}