summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/const_prop_miscompile.rs
blob: dbbe5ee08408f4b9c7d4ea1a783bf4cac5566da6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// unit-test: ConstProp
#![feature(raw_ref_op)]

// EMIT_MIR const_prop_miscompile.foo.ConstProp.diff
fn foo() {
    let mut u = (1,);
    *&mut u.0 = 5;
    let y = { u.0 } == 5;
}

// EMIT_MIR const_prop_miscompile.bar.ConstProp.diff
fn bar() {
    let mut v = (1,);
    unsafe {
        *&raw mut v.0 = 5;
    }
    let y = { v.0 } == 5;
}

fn main() {
    foo();
    bar();
}