]> git.lizzy.rs Git - rust.git/blob - src/test/ui/sanitize/address.rs
Merge commit '8f1ebdd18bdecc621f16baaf779898cc08cc2766' into clippyup
[rust.git] / src / test / ui / sanitize / address.rs
1 // needs-sanitizer-support
2 // needs-sanitizer-address
3 //
4 // compile-flags: -Z sanitizer=address -O -g
5 //
6 // run-fail
7 // error-pattern: AddressSanitizer: stack-buffer-overflow
8 // error-pattern: 'xs' (line 13) <== Memory access at offset
9
10 use std::hint::black_box;
11
12 fn main() {
13     let xs = [0, 1, 2, 3];
14     // Avoid optimizing everything out.
15     let xs = black_box(xs.as_ptr());
16     let code = unsafe { *xs.offset(4) };
17     std::process::exit(code);
18 }