Skip to content

Commit f28a9d8

Browse files
committed
rustc: Pointer cast when crossing a box boundary for statically-sized elements in trans_index()
1 parent 009e01d commit f28a9d8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/comp/middle/trans.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3892,6 +3892,10 @@ fn trans_index(@block_ctxt cx, &ast.span sp, @ast.expr base,
38923892
elt = next_cx.build.GEP(body, vec(C_int(0), scaled_ix));
38933893
} else {
38943894
elt = next_cx.build.GEP(body, vec(C_int(0), ix_val));
3895+
3896+
// We're crossing a box boundary here, so we may need to pointer cast.
3897+
auto llunitty = type_of(next_cx.fcx.ccx, unit_ty);
3898+
elt = next_cx.build.PointerCast(elt, T_ptr(llunitty));
38953899
}
38963900

38973901
ret lval_mem(next_cx, elt);

0 commit comments

Comments
 (0)