From 3d8c4d4fe9358d23d9edd6ac016477f91f1de997 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 25 Jan 2018 12:12:19 +0100 Subject: [PATCH] Don't read from zero sized fields --- src/librustc_mir/interpret/place.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index e82a252a95b3..4ca68068728d 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -123,6 +123,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { } let field_index = field.index(); let field = base_layout.field(self, field_index)?; + if field.size.bytes() == 0 { + return Ok(Some((Value::ByVal(PrimVal::Undef), field.ty))) + } let offset = base_layout.fields.offset(field_index); match base { // the field covers the entire type