Skip to content

Commit 03dfa5e

Browse files
committed
update fn ptr tests
1 parent 538aedf commit 03dfa5e

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

tests/compile-fail/validity/fn_ptr_offset.rs

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(invalid_value)]
22

33
fn main() {
4-
let _b: fn() = unsafe { std::mem::transmute(0usize) }; //~ ERROR encountered a potentially null function pointer
4+
let _b: fn() = unsafe { std::mem::transmute(0usize) }; //~ ERROR encountered a null function pointer
55
}

tests/run-pass/function_pointers.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ fn main() {
6262
// Any non-null value is okay for function pointers.
6363
unsafe {
6464
let _x: fn() = mem::transmute(1usize);
65-
let mut b = Box::new(42);
66-
let ptr = &mut *b as *mut _;
65+
let mut b = Box::new(42u8);
66+
let ptr = &mut *b as *mut u8;
6767
drop(b);
6868
let _x: fn() = mem::transmute(ptr);
69+
let _x: fn() = mem::transmute(ptr.wrapping_offset(1));
6970
}
7071
}

0 commit comments

Comments
 (0)