From 2f66e9417f51d4350274854287c52a106599f31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Christopher=20K=C3=B6hl?= Date: Wed, 5 Oct 2022 20:46:39 +0200 Subject: [PATCH] Flood with bottom for Deinit, StorageLive and StorageDead --- compiler/rustc_mir_dataflow/src/value_analysis.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 02b92ed7a62..1abfcacb0c0 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -91,12 +91,13 @@ pub trait ValueAnalysis<'tcx> { self.handle_intrinsic(intrinsic, state); } StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => { - // It is UB to read from an unitialized or unallocated local. - state.flood(Place::from(*local).as_ref(), self.map()); + // We can flood with bottom here, because `StorageLive` makes the local + // uninitialized, and `StorageDead` makes it UB to access. + state.flood_with(Place::from(*local).as_ref(), self.map(), Self::Value::bottom()); } StatementKind::Deinit(box place) => { - // It is UB to read `uninit` bytes. - state.flood(place.as_ref(), self.map()); + // The bottom states denotes uninitialized values. + state.flood_with(place.as_ref(), self.map(), Self::Value::bottom()); } StatementKind::Nop | StatementKind::Retag(..)