aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/issue-2080.rs
blob: 5fdf911efe1fe4a67c77a9ce04f64d97c67c57cb (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
// { dg-output "hello world: gccrs\r*\n" }
// { dg-additional-options "-w" }
static TEST_1: &str = "gccrs";
static TEST_2: i32 = 123;

struct Foo(i32, bool);
static TEST_3: Foo = Foo(123, false);

extern "C" {
    fn printf(s: *const i8, ...);
}

fn main() -> i32 {
    unsafe {
        let a1 = "hello world: %s\n";
        let b1 = a1 as *const str;
        let c1 = b1 as *const i8;

        let a2 = TEST_1;
        let b2 = a2 as *const str;
        let c2 = b2 as *const i8;

        printf(c1, c2);
    }
    0
}