]> git.lizzy.rs Git - rust.git/blob - src/test/ui/sanitize/issue-72154-lifetime-markers.rs
Auto merge of #2607 - RalfJung:rustup, r=RalfJung
[rust.git] / src / test / ui / sanitize / issue-72154-lifetime-markers.rs
1 // Regression test for issue 72154, where the use of AddressSanitizer enabled
2 // emission of lifetime markers during codegen, while at the same time asking
3 // always inliner pass not to insert them.  This eventually lead to a
4 // miscompilation which was subsequently detected by AddressSanitizer as UB.
5 //
6 // needs-sanitizer-support
7 // needs-sanitizer-address
8 //
9 // compile-flags: -Copt-level=0 -Zsanitizer=address
10 // run-pass
11
12 pub struct Wrap {
13     pub t: [usize; 1]
14 }
15
16 impl Wrap {
17     #[inline(always)]
18     pub fn new(t: [usize; 1]) -> Self {
19         Wrap { t }
20     }
21 }
22
23 #[inline(always)]
24 pub fn assume_init() -> [usize; 1] {
25     [1234]
26 }
27
28 fn main() {
29     let x: [usize; 1] = assume_init();
30     Wrap::new(x);
31 }