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

http://github.com/jruderman/rust · Rust · 11 lines · 6 code · 2 blank · 3 comment · 2 complexity · 176d9e4f0ec69b21d440a042506aeb4a MD5 · raw file

  1. // -*- rust -*-
  2. // error-pattern:bounds check
  3. fn main() {
  4. let v: ~[int] = ~[10];
  5. let x: int = 0;
  6. assert (v[x] == 10);
  7. // Bounds-check failure.
  8. assert (v[x + 2] == 20);
  9. }