Skip to content

Commit 2f66e94

Browse files
committed
Flood with bottom for Deinit, StorageLive and StorageDead
1 parent eab7732 commit 2f66e94

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/rustc_mir_dataflow/src/value_analysis.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ pub trait ValueAnalysis<'tcx> {
9191
self.handle_intrinsic(intrinsic, state);
9292
}
9393
StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => {
94-
// It is UB to read from an unitialized or unallocated local.
95-
state.flood(Place::from(*local).as_ref(), self.map());
94+
// We can flood with bottom here, because `StorageLive` makes the local
95+
// uninitialized, and `StorageDead` makes it UB to access.
96+
state.flood_with(Place::from(*local).as_ref(), self.map(), Self::Value::bottom());
9697
}
9798
StatementKind::Deinit(box place) => {
98-
// It is UB to read `uninit` bytes.
99-
state.flood(place.as_ref(), self.map());
99+
// The bottom states denotes uninitialized values.
100+
state.flood_with(place.as_ref(), self.map(), Self::Value::bottom());
100101
}
101102
StatementKind::Nop
102103
| StatementKind::Retag(..)

0 commit comments

Comments
 (0)