You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is interesting. We generally allow spec-mode reading from borrowed variables or variables whose values have moved, on the grounds that spec mode can read old copies of the data, and that this is sometimes convenient. For example:
struct S(u8);
fn f() {
let a = S(1);
let mut b = a;
b.0 = b.0 + 1;
assert(a.0 == 1);
}
We've also allowed assignments to spec values in the same way, which we also treat as assigning to old copies, though it's probably more an accident in the design than something intentional. At least, I don't see why it's useful:
struct S(Ghost<int>);
fn f() {
let mut a = S(Ghost(1));
let mut b = a;
proof { b.0@ = b.0@ + 1; }
assert(a.0@ == 1);
proof { a.0@ = 0; }
assert(a.0@ == 0);
assert(b.0@ == 2);
}
Should we be more restrictive towards writes than reads here? As we add more support for mutable references, there's always a danger that we don't encode the correct "copying" semantics in the SMT queries and therefore become unsound. Is this already a soundness issue, or is this something we should change now to prevent unsoundness in the future?
Y'know, I filed this because it seemed "obviously" unsound, but on second thought, I can't really think of a way to exploit it. After all, mutating the ghost state only ends up mutating anything in the encoding. Perhaps it's just confusing, not unsound. Not sure if the calculus changes when there's more general mutable reference support.
This should not pass:
The line
x.a = 5
modifiesx
which is currently borrowed, andx
is a tracked variable so should be subject to lifetime tracking.However, since
x.a
is a ghost field, lifetime-generate treats this assignment as if it can be ignored.The text was updated successfully, but these errors were encountered: