Skip to content

Commit

Permalink
Dangling pointers point to everything and nothing
Browse files Browse the repository at this point in the history
Co-authored-by: Ralf Jung <post@ralfj.de>
  • Loading branch information
oli-obk and RalfJung committed Jan 3, 2021
1 parent e5e4a85 commit 8968c8a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_mir/src/transform/check_consts/validation.rs
Expand Up @@ -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) {
Expand Down

0 comments on commit 8968c8a

Please sign in to comment.