]> git.proxmox.com Git - rustc.git/blob - src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.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 // min-llvm-version 9.0
6 // needs-sanitizer-support
7 // needs-sanitizer-address
8 //
9 // no-prefer-dynamic
10 // revisions: opt0 opt1
11 // compile-flags: -Znew-llvm-pass-manager=yes -Zsanitizer=address -Clto=thin
12 //[opt0]compile-flags: -Copt-level=0
13 //[opt1]compile-flags: -Copt-level=1
14 // run-fail
15 // error-pattern: ERROR: AddressSanitizer: stack-use-after-scope
16
17 static mut P: *mut usize = std::ptr::null_mut();
18
19 fn main() {
20 unsafe {
21 {
22 let mut x = 0;
23 P = &mut x;
24 }
25 std::ptr::write_volatile(P, 123);
26 }
27 }