-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed as not planned
Closed as not planned
Copy link
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-miriArea: The miri toolArea: The miri toolT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-miriArea: The miri toolArea: The miri toolT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.