-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validity of Box<T> #145
Comments
I think that the validity invariant of The safety invariant of |
|
Thanks for pointing that out. Summary from Discord chat with @rkruppe: Currently we generate We also talked about whether it would be possible to enforce |
We really emit |
@RalfJung This (https://rust.godbolt.org/z/E6Sl8a): fn foo(x: Box<i32>) -> i32 { *x } produces define i32 @foo(i32* noalias align 4 dereferenceable(4)) unnamed_addr #0 {
start:
%1 = load i32, i32* %0, align 4
%2 = bitcast i32* %0 to i8*
tail call void @__rust_dealloc(i8* nonnull %2, i64 4, i64 4) #1
ret i32 %1
} |
The godbolt link doesn't seem to produce dereferenceable any more |
Yes, that was changed with rust-lang/rust#66645. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I created #258 for the aliasing rules for Box. |
Some other issues that surely are relevant:
There are at least two questions which currently don't have another issue tracking them:
Basically there are a whole lot of axes and along each of them we can ask whether Box behaves like a reference or like I would say let's track aliasing in #326, and everything else here. The alignment question and |
What is the validity invariant of
Box<T>
? If this was just a library type it would be the same asUnique<T>
, which is the same asNonNull<T>
. But actually most of the compiler treatsBox<T>
a lot like a reference, so at least de-facto right now,Box<T>
likely has the same validity invariant as&T
and&mut T
(which is discussed in #76 and #77).Also see some prior discussion in rust-lang/rust-memory-model#3.
The text was updated successfully, but these errors were encountered: