aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/issue-852.rs
blob: 763105d27497137fb9149c055c960a18dfd4dfe4 (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
29
30
// { dg-options "-w" }
extern "C" {
    fn printf(s: *const i8, ...);
}

enum Foo {
    A,
    B(i32),
}

fn main() {
    let result = Foo::B(123);

    match result {
        A => unsafe {
            let a = "A\n\0";
            let b = a as *const str;
            let c = b as *const i8;

            printf(c);
        },
        Foo::B(x) => unsafe {
            let a = "Result: %i\n\0";
            let b = a as *const str;
            let c = b as *const i8;

            printf(c, x);
        },
    }
}