From 578fcdef5fbd02bd3ae7d30349f62aa9143a0bf2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 15 Mar 2021 10:22:21 +0100 Subject: [PATCH] Special case ZST's in Rvalue::Repeat Fixes #1146 by preventing a hang for [(); usize::MAX], which is used in a test of libcore. --- src/base.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 362ba7e1c2c..5a28656add2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -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);