]> git.lizzy.rs Git - rust.git/blob - tests/run-pass-noseed/ptr_offset.rs
temporarily disable ptr_offset, maybe that helps
[rust.git] / tests / run-pass-noseed / ptr_offset.rs
1 // FIXME move this to run-pass, it should work with intptrcast.
2
3 fn f() -> i32 { 42 }
4
5 fn main() {
6     let v = [1i16, 2];
7     let x = &v as *const [i16; 2] as *const i16;
8     let x = unsafe { x.offset(1) };
9     assert_eq!(unsafe { *x }, 2);
10
11     // fn ptr offset
12     unsafe {
13         let p = f as fn() -> i32 as usize;
14         let x = (p as *mut u32).offset(0) as usize;
15         let f: fn() -> i32 = std::mem::transmute(x);
16         assert_eq!(f(), 42);
17     }
18 }