]> git.lizzy.rs Git - rust.git/blob - src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs
Rollup merge of #102634 - andrewpollack:refactor-test-rustcflags, r=Mark-Simulacrum
[rust.git] / src / test / ui / sanitize / new-llvm-pass-manager-thin-lto.rs
1 // Regression test for sanitizer function instrumentation passes not
2 // being run when compiling with new LLVM pass manager and ThinLTO.
3 // Note: The issue occurred only on non-zero opt-level.
4 //
5 // needs-sanitizer-support
6 // needs-sanitizer-address
7 //
8 // no-prefer-dynamic
9 // revisions: opt0 opt1
10 // compile-flags: -Zsanitizer=address -Clto=thin
11 //[opt0]compile-flags: -Copt-level=0
12 //[opt1]compile-flags: -Copt-level=1
13 // run-fail
14 // error-pattern: ERROR: AddressSanitizer: stack-use-after-scope
15
16 static mut P: *mut usize = std::ptr::null_mut();
17
18 fn main() {
19     unsafe {
20         {
21             let mut x = 0;
22             P = &mut x;
23         }
24         std::ptr::write_volatile(P, 123);
25     }
26 }