diff --git a/tests/compile-fail/fn_ptr_offset.rs b/tests/compile-fail/fn_ptr_offset.rs new file mode 100644 index 00000000000..2d240b6a55a --- /dev/null +++ b/tests/compile-fail/fn_ptr_offset.rs @@ -0,0 +1,11 @@ +use std::mem; + +fn f() {} + +fn main() { + let x : fn() = f; + let y : *mut u8 = unsafe { mem::transmute(x) }; + let y = y.wrapping_offset(1); + let x : fn() = unsafe { mem::transmute(y) }; + x(); //~ ERROR: tried to use an integer pointer or a dangling pointer as a function pointer +} diff --git a/tests/run-pass/thread-local.rs b/tests/run-pass/thread-local.rs index 003fd1ad4c0..34aeef23b1a 100644 --- a/tests/run-pass/thread-local.rs +++ b/tests/run-pass/thread-local.rs @@ -42,7 +42,7 @@ unsafe extern fn dtor(mut ptr: *mut u64) { } // Check if the records matches what we expect. If yes, clear the cannary. - // If the record is wrong, the cannary will ever get cleared, leading to a leak -> test fails. + // If the record is wrong, the cannary will never get cleared, leading to a leak -> test fails. // If the record is incomplete (i.e., more dtor calls happen), the check at the beginning of this function will fail -> test fails. // The correct sequence is: First key 0, then key 1, then key 0. if RECORD == 0_1_0 {