mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
17 lines
298 B
Rust
17 lines
298 B
Rust
//@ run-pass
|
|
//@ compile-flags: -O
|
|
|
|
// Regression test for issue #80309
|
|
|
|
pub fn zero(x: usize) -> usize {
|
|
std::ptr::null::<i8>().wrapping_add(x) as usize - x
|
|
}
|
|
pub fn qux(x: &[i8]) -> i8 {
|
|
x[zero(x.as_ptr() as usize)]
|
|
}
|
|
|
|
fn main() {
|
|
let z = vec![42, 43];
|
|
println!("{}", qux(&z));
|
|
}
|