Skip to content

Commit 1cf13a4

Browse files
committed
Don't pass an undef retptr to generic intrinsics
It leads to segfaults
1 parent 1fac439 commit 1cf13a4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/rustc/middle/trans/base.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,9 +2649,8 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr,
26492649
// - new_fn_ctxt
26502650
// - trans_args
26512651
fn trans_args(cx: block, llenv: ValueRef, es: [@ast::expr], fn_ty: ty::t,
2652-
dest: dest) -> {bcx: block,
2653-
args: [ValueRef],
2654-
retslot: ValueRef} {
2652+
dest: dest, generic_intrinsic: bool)
2653+
-> {bcx: block, args: [ValueRef], retslot: ValueRef} {
26552654

26562655
let temp_cleanups = [];
26572656
let args = ty::ty_fn_args(fn_ty);
@@ -2664,7 +2663,7 @@ fn trans_args(cx: block, llenv: ValueRef, es: [@ast::expr], fn_ty: ty::t,
26642663
// Arg 0: Output pointer.
26652664
let llretslot = alt dest {
26662665
ignore {
2667-
if ty::type_is_nil(retty) {
2666+
if ty::type_is_nil(retty) && !generic_intrinsic {
26682667
llvm::LLVMGetUndef(T_ptr(T_nil()))
26692668
} else {
26702669
let {bcx: cx, val} = alloc_ty(bcx, retty);
@@ -2748,7 +2747,8 @@ fn trans_call_inner(in_cx: block, fn_expr_ty: ty::t,
27482747
};
27492748

27502749
let ret_ty = node_id_type(bcx, id);
2751-
let args_res = trans_args(bcx, llenv, args, fn_expr_ty, dest);
2750+
let args_res = trans_args(bcx, llenv, args, fn_expr_ty, dest,
2751+
option::is_some(f_res.tds));
27522752
bcx = args_res.bcx;
27532753
let llargs = args_res.args;
27542754
option::may(f_res.tds) {|vals|

0 commit comments

Comments
 (0)