Deallocate primval conversion hack allocs.

It's a hack, sure, but it should learn some manners.
This commit is contained in:
Scott Olson 2016-10-16 03:21:41 -06:00
parent 55f2164bcd
commit b1094f6c1e
2 changed files with 13 additions and 2 deletions

View File

@ -1124,7 +1124,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
Value::ByVal(primval) => {
let ptr = self.alloc_ptr(ty)?;
self.memory.write_primval(ptr, primval)?;
self.value_to_primval(Value::ByRef(ptr), ty)
let primval = self.value_to_primval(Value::ByRef(ptr), ty)?;
self.memory.deallocate(ptr)?;
Ok(primval)
}
Value::ByValPair(..) => bug!("value_to_primval can't work with fat pointers"),

View File

@ -2,7 +2,7 @@
#![miri(memory_size=1000)]
fn bar(i: i32) {
if i < 1000 { //~ERROR tried to allocate 4 more bytes, but only 1 bytes are free of the 1000 byte memory
if i < 1000 { //~ERROR tried to allocate 4 more bytes, but only 0 bytes are free of the 1000 byte memory
bar(i + 1)
//~^NOTE inside call to bar
//~|NOTE inside call to bar
@ -31,6 +31,15 @@ fn bar(i: i32) {
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
}
}