2024-02-16 20:02:50 +00:00
|
|
|
//@ needs-sanitizer-support
|
|
|
|
|
//@ needs-sanitizer-address
|
|
|
|
|
//@ ignore-cross-compile
|
2020-01-27 00:00:00 +00:00
|
|
|
//
|
2025-03-20 12:43:44 +07:00
|
|
|
//@ compile-flags: -Zsanitizer=address -C unsafe-allow-abi-mismatch=sanitizer
|
2025-06-25 07:56:40 +02:00
|
|
|
//@ run-fail-or-crash
|
2024-02-16 20:02:50 +00:00
|
|
|
//@ error-pattern: ERROR: AddressSanitizer: stack-use-after-scope
|
2020-01-27 00:00:00 +00:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|