Closed as not planned
Description
The Miri core engine can only represent "full" pointers in memory, no parts of a pointer. This leads to strange behavior on code like
let mut p = &42;
unsafe {
let ptr: *mut _ = &mut p;
*(ptr as *mut u8) = 123; // overwrite the first byte of the pointer
}
let x = *p; //~ ERROR this operation requires initialized memory
If overwriting a part of a pointer happens during CTFE, we halt execution (since #87248). In Miri, instead we de-initialize the entire pointer, so a write will affect the bytes "next to it". (Halting execution is not an option here.)
If loading a part of a pointer (including as the source of a mem-to-mem copy) happens during CTFE or Miri, we halt execution.
Long-term, it would be great to implement support for having just a few bytes of a pointer in a Miri core engine Allocation
. However, this might be hard to do without a perf regression.
Cc @rust-lang/wg-const-eval