Dangling pointers point to everything and nothing

Co-authored-by: Ralf Jung <post@ralfj.de>
This commit is contained in:
Oli Scherer 2021-01-03 15:19:07 +01:00 committed by GitHub
parent e5e4a851c4
commit 8968c8a103
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -595,8 +595,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
// Locals with StorageDead are definitely not part of the final constant value, and
// it is thus inherently safe to permit such locals to have their
// address taken as we can't end up with a reference to them in the
// final value without creating a dangling pointer, which will cause
// errors during validation.
// final value.
// Note: This is only sound if every local that has a `StorageDead` has a
// `StorageDead` in every control flow path leading to a `return` terminator.
if self.local_has_storage_dead(place.local) {