use as(_mut)_ptr on slices to entirely escape them to raw
This commit is contained in:
parent
44b3c38b44
commit
8cd73e534f
2 changed files with 3 additions and 8 deletions
|
|
@ -10,17 +10,13 @@
|
|||
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
// FIXME: Validation disabled because it doesn't let us escape an entire slice
|
||||
// to the raw universe.
|
||||
// compile-flags: -Zmiri-disable-validation
|
||||
|
||||
//error-pattern: copy_nonoverlapping called on overlapping ranges
|
||||
|
||||
fn main() {
|
||||
let mut data = [0u8; 16];
|
||||
unsafe {
|
||||
let a = &data[0] as *const _;
|
||||
let b = &mut data[1] as *mut _;
|
||||
let a = data.as_mut_ptr();
|
||||
let b = a.wrapping_offset(1) as *mut _;
|
||||
std::ptr::copy_nonoverlapping(a, b, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
fn main() {
|
||||
let v = [1i16, 2];
|
||||
let x = &v[1] as *const i16;
|
||||
let _ = &v[0] as *const i16; // we need to leak the 2nd thing too or it cannot be accessed through a raw ptr
|
||||
let x = v.as_ptr().wrapping_offset(1); // ptr to the 2nd element
|
||||
// Adding 2*isize::max and then 1 is like substracting 1
|
||||
let x = x.wrapping_offset(isize::max_value());
|
||||
let x = x.wrapping_offset(isize::max_value());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue