Change:
Array created using repeat expression and returned from a function actually returns . Interestingly the problem does not happen when using the list syntax to create the array. I tried this code: I expected to see this happen: the second should pass Instead, this happened: the second fails screaming that Problem exists on stable, beta and nightly : <details<summaryBacktrace</summary<p</p</details
I wonder if is at fault here. It does look to be inappropriately turning the repeat into a memset (when looking at the llvm IR)
Compiling this: with Yields: Which does not seem right. We shouldn't be emitting a memset to 0 there.
This program hits an LLVM assertion if compiled with an LLVM that has assertions enabled:
This appeared in . Until the sample would code emit a compile error (), maybe that would shadow the error? A bisection between those two stable releases points to a group of old PR but I can't really pinpoint one :/
fails even under 1.26. And before that, i128 didn't even exist. So this has been a problem since 128 bit ints were introduced, as far as I can see.
Thank you for the analysis and the fix :)
WG-prioritization assigning priority (). label -I-prioritize +P-critical

Discussion:
} fn const_to_opt_uint(&self, v: &'ll Value) -> Option<u64> { <del> try_as_const_integral(v).map(|v| unsafe { llvm::LLVMConstIntGetZExtValue(v) }) </del> <ins> try_as_const_integral(v).and_then(|v| unsafe { let mut i = 0u64; let success = llvm::LLVMRustConstIntGetZExtValue(v, &mut i); success.then_some(i) }) </ins> } fn const_to_opt_u128(&self, v: &'ll Value, sign_ext: bool) -> Option<u128> {

pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value; pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value; pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value; <del> pub fn LLVMConstIntGetZExtValue(ConstantVal: &ConstantInt) -> c_ulonglong; </del> <ins> pub fn LLVMRustConstIntGetZExtValue(ConstantVal: &ConstantInt, Value: &mut u64) -> bool; </ins> pub fn LLVMRustConstInt128Get( ConstantVal: &ConstantInt, SExt: bool,

let size = bx.const_usize(dest.layout.size.bytes()); // Use llvm.memset.p0i8.* to initialize all zero arrays <del> if bx.cx().const_to_opt_uint(v) == Some(0) { </del> <ins> if bx.cx().const_to_opt_u128(v, false) == Some(0) { </ins> let fill = bx.cx().const_u8(0); bx.memset(start, fill, size, dest.align, MemFlags::empty()); return bx;

return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList)); } <ins> extern "C" bool LLVMRustConstIntGetZExtValue(LLVMValueRef CV, uint64_t *value) { auto C = unwrap<llvm::ConstantInt>(CV); if (C->getBitWidth() > 64) return false; *value = C->getZExtValue(); return true; } </ins> // Returns true if both high and low were successfully set. Fails in case constant wasn’t any of // the common sizes (1, 8, 16, 32, 64, 128 bits) extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *high, uint64_t *low)

<ins> // Regression test for issue 101585. // run-pass fn main() { fn min_array_ok() -> [i128; 1] { [i128::MIN] } assert_eq!(min_array_ok(), [-170141183460469231731687303715884105728i128]); fn min_array_nok() -> [i128; 1] { [i128::MIN; 1] } assert_eq!(min_array_nok(), [-170141183460469231731687303715884105728i128]); } </ins>