2012-06-06 18:01:12 -05:00
|
|
|
// xfail-test
|
|
|
|
// error-pattern:bounds check
|
|
|
|
|
|
|
|
fn main() {
|
2012-06-29 18:26:56 -05:00
|
|
|
let x = ~[1u,2u,3u];
|
2012-06-06 18:01:12 -05:00
|
|
|
|
|
|
|
// This should cause a bounds-check failure, but may not if we do our
|
|
|
|
// bounds checking by comparing a scaled index value to the vector's
|
|
|
|
// length (in bytes), because the scaling of the index will cause it to
|
|
|
|
// wrap around to a small number.
|
|
|
|
|
|
|
|
let idx = uint::max_value & !(uint::max_value >> 1u);
|
2012-08-22 19:24:52 -05:00
|
|
|
error!("ov2 idx = 0x%x", idx);
|
2012-06-06 18:01:12 -05:00
|
|
|
|
|
|
|
// This should fail.
|
2012-08-22 19:24:52 -05:00
|
|
|
error!("ov2 0x%x", x[idx]);
|
2012-06-06 18:01:12 -05:00
|
|
|
}
|