mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
19 lines
369 B
Rust
19 lines
369 B
Rust
// needs-sanitizer-support
|
|
// needs-sanitizer-address
|
|
//
|
|
// compile-flags: -Zsanitizer=address
|
|
// run-fail
|
|
// error-pattern: ERROR: AddressSanitizer: stack-use-after-scope
|
|
|
|
static mut P: *mut usize = std::ptr::null_mut();
|
|
|
|
fn main() {
|
|
unsafe {
|
|
{
|
|
let mut x = 0;
|
|
P = &mut x;
|
|
}
|
|
std::ptr::write_volatile(P, 123);
|
|
}
|
|
}
|