about summary refs log tree commit diff
path: root/tests/mir-opt/dest-prop/nrvo_miscompile_111005.rs
blob: 17e6450278ac61df2b5becd49133c4b18303b011 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// This is a miscompilation, #111005 to track

//@ test-mir-pass: DestinationPropagation

#![feature(custom_mir, core_intrinsics)]
extern crate core;
use core::intrinsics::mir::*;

// EMIT_MIR nrvo_miscompile_111005.wrong.DestinationPropagation.diff
#[custom_mir(dialect = "runtime", phase = "initial")]
pub fn wrong(arg: char) -> char {
    // CHECK-LABEL: fn wrong(
    // CHECK: _0 = copy _1;
    // CHECK-NEXT: _1 = const 'b';
    // CHECK-NEXT: return;
    mir! {
        {
            let temp = arg;
            RET = temp;
            temp = 'b';
            Return()
        }
    }
}

fn main() {
    assert_eq!(wrong('a'), 'a');
}