Skip to content

Commit 7ea3a7b

Browse files
committed
Don't pass an undef retptr to generic intrinsics
It leads to segfaults
1 parent f56f8b8 commit 7ea3a7b

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
@@ -2660,9 +2660,8 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr,
26602660
// - new_fn_ctxt
26612661
// - trans_args
26622662
fn trans_args(cx: block, llenv: ValueRef, es: [@ast::expr], fn_ty: ty::t,
2663-
dest: dest) -> {bcx: block,
2664-
args: [ValueRef],
2665-
retslot: ValueRef} {
2663+
dest: dest, generic_intrinsic: bool)
2664+
-> {bcx: block, args: [ValueRef], retslot: ValueRef} {
26662665

26672666
let temp_cleanups = [];
26682667
let args = ty::ty_fn_args(fn_ty);
@@ -2675,7 +2674,7 @@ fn trans_args(cx: block, llenv: ValueRef, es: [@ast::expr], fn_ty: ty::t,
26752674
// Arg 0: Output pointer.
26762675
let llretslot = alt dest {
26772676
ignore {
2678-
if ty::type_is_nil(retty) {
2677+
if ty::type_is_nil(retty) && !generic_intrinsic {
26792678
llvm::LLVMGetUndef(T_ptr(T_nil()))
26802679
} else {
26812680
let {bcx: cx, val} = alloc_ty(bcx, retty);
@@ -2759,7 +2758,8 @@ fn trans_call_inner(in_cx: block, fn_expr_ty: ty::t,
27592758
};
27602759

27612760
let ret_ty = node_id_type(bcx, id);
2762-
let args_res = trans_args(bcx, llenv, args, fn_expr_ty, dest);
2761+
let args_res = trans_args(bcx, llenv, args, fn_expr_ty, dest,
2762+
option::is_some(f_res.tds));
27632763
bcx = args_res.bcx;
27642764
let llargs = args_res.args;
27652765
option::may(f_res.tds) {|vals|

0 commit comments

Comments
 (0)