aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/unsafe4.rs
blob: 7d1356bc3e588058ebb0a8ca44fcd32a85281ee1 (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
fn foo() -> i32 {
    let a = 15;
    let p_a = &a as *const i32;

    unsafe { *p_a }
}

unsafe fn bar() -> i32 {
    let a = 15;
    let p_a = &a as *const i32;

    *p_a
}

fn baz() -> i32 {
    let a = 15;
    let p_a = &a as *const i32;

    *p_a // { dg-error "dereference of raw pointer" }
}

unsafe fn qux() -> i32 {
    let a = 15;
    let p_a = &a as *const i32;

    unsafe {}

    *p_a
}