]> git.lizzy.rs Git - rust.git/blob - src/test/ui/sanitize/address.rs
Rollup merge of #70038 - DutchGhost:const-forget-tests, r=RalfJung
[rust.git] / src / test / ui / sanitize / address.rs
1 // needs-sanitizer-support
2 // only-x86_64
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 15) <== Memory access at offset
9
10 #![feature(test)]
11
12 use std::hint::black_box;
13
14 fn main() {
15     let xs = [0, 1, 2, 3];
16     // Avoid optimizing everything out.
17     let xs = black_box(xs.as_ptr());
18     let code = unsafe { *xs.offset(4) };
19     std::process::exit(code);
20 }