]>
Commit | Line | Data |
---|---|---|
f9f354fc XL |
1 | // run-pass |
2 | ||
3 | // When the NRVO is applied, the return place (`_0`) gets treated like a normal local. For example, | |
4 | // its address may be taken and it may be written to indirectly. Ensure that MIRI can handle this. | |
5 | ||
6 | #![feature(const_mut_refs)] | |
7 | ||
8 | #[inline(never)] // Try to ensure that MIR optimizations don't optimize this away. | |
9 | const fn init(buf: &mut [u8; 1024]) { | |
10 | buf[33] = 3; | |
11 | buf[444] = 4; | |
12 | } | |
13 | ||
14 | const fn nrvo() -> [u8; 1024] { | |
15 | let mut buf = [0; 1024]; | |
16 | init(&mut buf); | |
17 | buf | |
18 | } | |
19 | ||
20 | const BUF: [u8; 1024] = nrvo(); | |
21 | ||
22 | fn main() { | |
23 | assert_eq!(BUF[33], 3); | |
24 | assert_eq!(BUF[19], 0); | |
25 | assert_eq!(BUF[444], 4); | |
26 | } |