IndirectlyMutableLocals
analysis is unsound in the presence of unsafe code
#65006
Labels
A-const-eval
Area: Constant evaluation (MIR interpretation)
C-bug
Category: This is a bug.
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
#64470 added an
IndirectlyMutableLocals
analysis to track whether a local could possibly be mutated through a pointer at a given point in the program. However, this analysis overlooked the fact that a shared reference to aFreeze
field of a struct could be converted to a shared reference to a!Freeze
field of that same struct by offsetting a pointer.This does not currently cause any unsoundness in the language, since this analysis is only used in const contexts, where the required operations are forbidden. However, we need to fix this before it becomes possible to take a mutable reference or mutate an
UnsafeCell
or other!Freeze
type in a const context.#64980 added a test that demonstrates the incorrect behavior.
The text was updated successfully, but these errors were encountered: