blob: 1e36cf4f3d316dcea57bc03ce920209e5dfc0827 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Compiler:
//
// Run-time:
// status: 0
// stdout: 10
// 14
// 1
// 12
// 12
// 1
#![feature(no_core)]
#![no_std]
#![no_core]
#![no_main]
extern crate mini_core;
use mini_core::*;
struct Test {
field: isize,
}
struct WithRef {
refe: &'static Test,
}
static mut CONSTANT: isize = 10;
static mut TEST: Test = Test { field: 12 };
static mut TEST2: Test = Test { field: 14 };
static mut WITH_REF: WithRef = WithRef { refe: unsafe { &TEST } };
#[no_mangle]
extern "C" fn main(argc: isize, _argv: *const *const u8) -> i32 {
unsafe {
libc::printf(b"%ld\n\0" as *const u8 as *const i8, CONSTANT);
libc::printf(b"%ld\n\0" as *const u8 as *const i8, TEST2.field);
TEST2.field = argc;
libc::printf(b"%ld\n\0" as *const u8 as *const i8, TEST2.field);
libc::printf(b"%ld\n\0" as *const u8 as *const i8, WITH_REF.refe.field);
WITH_REF.refe = &TEST2;
libc::printf(b"%ld\n\0" as *const u8 as *const i8, TEST.field);
libc::printf(b"%ld\n\0" as *const u8 as *const i8, WITH_REF.refe.field);
}
0
}
|