summaryrefslogtreecommitdiffstats
path: root/tests/ui/issues/issue-82833-slice-miscompile.rs
blob: 8cf6a3137e2d6303fc216faf3b17b724bc0a8452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// run-pass
// compile-flags: -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Copt-level=0 -Cdebuginfo=2

// Make sure LLVM does not miscompile this.

fn make_string(ch: char) -> String {
    let mut bytes = [0u8; 4];
    ch.encode_utf8(&mut bytes).into()
}

fn main() {
    let ch = '😃';
    dbg!(ch);
    let string = make_string(ch);
    dbg!(string);
}