1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 // error-pattern:index out of bounds
17 let x = vec!(1u,2u,3u);
19 // This should cause a bounds-check panic, but may not if we do our
20 // bounds checking by comparing a scaled index value to the vector's
21 // length (in bytes), because the scaling of the index will cause it to
22 // wrap around to a small number.
24 let idx = uint::MAX & !(uint::MAX >> 1u);
25 println!("ov2 idx = 0x%x", idx);
28 println!("ov2 0x%x", x[idx]);