mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
6d75f54310
Moves the sanitizer ui tests to the sanitizer directory and removes the sanitizer prefix from tests file names similarly to how the sanitizer codegen tests are organized.
20 lines
484 B
Rust
20 lines
484 B
Rust
//@ needs-sanitizer-support
|
|
//@ needs-sanitizer-address
|
|
//@ ignore-cross-compile
|
|
//
|
|
//@ compile-flags: -Z sanitizer=address -O -g
|
|
//
|
|
//@ run-fail
|
|
//@ error-pattern: AddressSanitizer: stack-buffer-overflow
|
|
//@ error-pattern: 'xs' (line 14) <== Memory access at offset
|
|
|
|
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);
|
|
}
|