]>
Commit | Line | Data |
---|---|---|
9ffffee4 FG |
1 | // This attempts to modify `x.1` via a pointer derived from `addr_of_mut!(x.0)`. |
2 | // According to Miri, that is UB. However, T-opsem has not finalized that | |
3 | // decision and as such we cannot rely on it in optimizations. Consequently, | |
4 | // DataflowConstProp must treat the `addr_of_mut!(x.0)` as potentially being | |
5 | // used to modify `x.1` - if it did not, then it might incorrectly assume that it | |
6 | // can infer the value of `x.1` at the end of this function. | |
7 | ||
487cf647 FG |
8 | // unit-test: DataflowConstProp |
9 | ||
10 | // EMIT_MIR sibling_ptr.main.DataflowConstProp.diff | |
11 | fn main() { | |
12 | let mut x: (u8, u8) = (0, 0); | |
13 | unsafe { | |
14 | let p = std::ptr::addr_of_mut!(x.0); | |
15 | *p.add(1) = 1; | |
16 | } | |
9ffffee4 | 17 | let x1 = x.1; // should not be propagated |
487cf647 | 18 | } |