2020-01-15 18:00:00 -06:00
|
|
|
// needs-sanitizer-support
|
2020-06-04 19:00:00 -05:00
|
|
|
// needs-sanitizer-address
|
2020-01-15 18:00:00 -06:00
|
|
|
//
|
2020-03-06 18:00:00 -06:00
|
|
|
// compile-flags: -Z sanitizer=address -O -g
|
2020-01-15 18:00:00 -06:00
|
|
|
//
|
|
|
|
// run-fail
|
|
|
|
// error-pattern: AddressSanitizer: stack-buffer-overflow
|
2022-09-24 05:34:56 -05:00
|
|
|
// error-pattern: 'xs' (line 13) <== Memory access at offset
|
2020-01-15 18:00:00 -06:00
|
|
|
|
|
|
|
use std::hint::black_box;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let xs = [0, 1, 2, 3];
|
|
|
|
// Avoid optimizing everything out.
|
|
|
|
let xs = black_box(xs.as_ptr());
|
|
|
|
let code = unsafe { *xs.offset(4) };
|
|
|
|
std::process::exit(code);
|
|
|
|
}
|