2022-02-04 08:11:51 -06:00
|
|
|
//@ run-pass
|
2022-02-21 19:53:16 -06:00
|
|
|
//@ compile-flags: -O
|
2022-02-04 08:11:51 -06:00
|
|
|
|
|
|
|
// 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));
|
|
|
|
}
|