Fix allocation of fn items by allowing ZST alignment to be 0.

This commit is contained in:
Scott Olson 2016-09-13 21:31:12 -06:00
parent 2e70fcdca8
commit f731766805

View File

@ -173,10 +173,11 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
} }
pub fn allocate(&mut self, size: usize, align: usize) -> EvalResult<'tcx, Pointer> { pub fn allocate(&mut self, size: usize, align: usize) -> EvalResult<'tcx, Pointer> {
assert!(align != 0);
if size == 0 { if size == 0 {
return Ok(Pointer::zst_ptr()); return Ok(Pointer::zst_ptr());
} }
assert!(align != 0);
if self.memory_size - self.memory_usage < size { if self.memory_size - self.memory_usage < size {
return Err(EvalError::OutOfMemory { return Err(EvalError::OutOfMemory {
allocation_size: size, allocation_size: size,