Use precise return type to allocate retslot in trans_args
Using type_of_or_i8 did, predictably, allocate an i8 for a type parameter, which leads to memory corruption and general confusion. Closes #1443
This commit is contained in:
parent
75f84b2563
commit
54cf0e9c0d
|
@ -3176,15 +3176,22 @@ fn trans_args(cx: @block_ctxt, llenv: ValueRef,
|
|||
_ { }
|
||||
}
|
||||
// Arg 0: Output pointer.
|
||||
let llretty = type_of_or_i8(bcx, full_retty);
|
||||
let llretslot = alt dest {
|
||||
ignore. {
|
||||
if ty::type_is_nil(tcx, retty) {
|
||||
llvm::LLVMGetUndef(T_ptr(llretty))
|
||||
} else { alloca(cx, llretty) }
|
||||
llvm::LLVMGetUndef(T_ptr(T_nil()))
|
||||
} else {
|
||||
let {bcx: cx, val} = alloc_ty(bcx, full_retty);
|
||||
bcx = cx;
|
||||
val
|
||||
}
|
||||
}
|
||||
save_in(dst) { dst }
|
||||
by_val(_) { alloca(cx, llretty) }
|
||||
by_val(_) {
|
||||
let {bcx: cx, val} = alloc_ty(bcx, full_retty);
|
||||
bcx = cx;
|
||||
val
|
||||
}
|
||||
};
|
||||
|
||||
if ty::type_contains_params(tcx, retty) {
|
||||
|
|
Loading…
Reference in New Issue