1
Fork 0

Don't read from zero sized fields

This commit is contained in:
Oliver Schneider 2018-01-25 12:12:19 +01:00
parent d26ebec81c
commit 3d8c4d4fe9
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9

View file

@ -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