Skip to content

Commit

Permalink
Special case ZST's in Rvalue::Repeat
Browse files Browse the repository at this point in the history
Fixes rust-lang#1146 by preventing a hang for [(); usize::MAX], which is used in
a test of libcore.
  • Loading branch information
bjorn3 committed Mar 15, 2021
1 parent 6b58ed2 commit 578fcde
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,9 @@ fn codegen_stmt<'tcx>(
.val
.try_to_bits(fx.tcx.data_layout.pointer_size)
.unwrap();
if fx.clif_type(operand.layout().ty) == Some(types::I8) {
if operand.layout().size.bytes() == 0 {
// Do nothing for ZST's
} else if fx.clif_type(operand.layout().ty) == Some(types::I8) {
let times = fx.bcx.ins().iconst(fx.pointer_type, times as i64);
// FIXME use emit_small_memset where possible
let addr = lval.to_ptr().get_addr(fx);
Expand Down

0 comments on commit 578fcde

Please sign in to comment.