Skip to content

Commit 578fcde

Browse files
committed
Special case ZST's in Rvalue::Repeat
Fixes rust-lang#1146 by preventing a hang for [(); usize::MAX], which is used in a test of libcore.
1 parent 6b58ed2 commit 578fcde

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/base.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,9 @@ fn codegen_stmt<'tcx>(
660660
.val
661661
.try_to_bits(fx.tcx.data_layout.pointer_size)
662662
.unwrap();
663-
if fx.clif_type(operand.layout().ty) == Some(types::I8) {
663+
if operand.layout().size.bytes() == 0 {
664+
// Do nothing for ZST's
665+
} else if fx.clif_type(operand.layout().ty) == Some(types::I8) {
664666
let times = fx.bcx.ins().iconst(fx.pointer_type, times as i64);
665667
// FIXME use emit_small_memset where possible
666668
let addr = lval.to_ptr().get_addr(fx);

0 commit comments

Comments
 (0)