-
Notifications
You must be signed in to change notification settings - Fork 58
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
What about: validity after/during drop #268
Comments
This looks like a dup of #245
I would say that does invoke UB, because you could have something like this: struct Foo {
weird: ManuallyDrop<Weird>,
something_else: Box<u32>,
}
impl Drop for Foo {
fn drop(&mut self) {
unsafe { ManuallyDrop::drop(&mut self.weird); }
println!("{}", self.something_else);
}
}
fn main() {
let foo = Some(Foo { ... });
drop(foo);
}
|
At least currently, the UB arises whenever any kind of "typed operation" is done on an invalid value. The compiler will prevent doing anything on the However, I also think that validity should be a bit-level property. So it's not validity that requires |
I think this was addressed enough to close. Though I've a different validity after drop issue I'm about to open, so that's the real motivation to closing this... |
e.g.
Box<T>
potentially has a validity requirement of being dereferencable.<Box<T> as Drop>::drop
obviously breaks this requirement, and at the end of the function, theBox<T>
still exists, but the pointer is now dangling.That one is probably directly handled by
#[may_dangle]
, so what about this minimal example:Does the indicated line invoke UB? When the allocated place is
Weird
? When the allocated place isOption<Weird>
(#204 IIRC)?The text was updated successfully, but these errors were encountered: