]>
git.proxmox.com Git - rustc.git/blob - src/test/run-fail/bug-2470-bounds-check-overflow-3.rs
b7aff8d1be1e2373e69d8e0d782d02f22091dc3d
1 // Copyright 2012-2015 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
16 #[cfg(target_arch="x86")]
18 let x
= vec
!(1_usize
,2_usize
,3_usize
);
20 // This should cause a bounds-check panic, but may not if we do our
21 // bounds checking by truncating the index value to the size of the
22 // machine word, losing relevant bits of the index value.
24 // This test is only meaningful on 32-bit hosts.
26 let idx
= u64::MAX
& !(u64::MAX
>> 1_usize
);
27 println
!("ov3 idx = 0x%8.8x%8.8x",
32 println
!("ov3 0x%x", x
[idx
]);
35 #[cfg(any(target_arch="x86_64", target_arch = "aarch64"))]
37 // This version just panics anyways, for symmetry on 64-bit hosts.
38 let x
= vec
!(1_usize
,2_usize
,3_usize
);
39 error
!("ov3 0x%x", x
[200]);