Currently, the following is illegal according to Stacked Borrows:
let val = [1u8, 2];
let ptr = &val[0] as *const u8;
let _val = unsafe { *ptr.add(1) };
The problem is that the cast to *const u8 creates a raw pointer that may only be used for the u8 it points to, not anything else. The most common case is to do &slice[0] as *const _ instead of slice.as_ptr().
This has lead to problems:
Maybe this is too restrictive and raw pointers should be allowed to access their "surroundings"? I am not sure what exactly that would look like though. It would probably require having the raw pointer fully inherit all permissions from the reference it is created from.
I'll use this issue to collect such cases.
Currently, the following is illegal according to Stacked Borrows:
The problem is that the cast to
*const u8creates a raw pointer that may only be used for theu8it points to, not anything else. The most common case is to do&slice[0] as *const _instead ofslice.as_ptr().This has lead to problems:
&slice[0]thing.Rc::into_raw+Rc::from_rawdon't work well together because of this.&slice[0]patternMaybe this is too restrictive and raw pointers should be allowed to access their "surroundings"? I am not sure what exactly that would look like though. It would probably require having the raw pointer fully inherit all permissions from the reference it is created from.
I'll use this issue to collect such cases.