From 041a8c4bd3a13eb9f8b99f0b8131321f0eafef68 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Sun, 10 May 2009 22:26:04 +0200 Subject: [PATCH] Fix DtoArrayCopyToSlice by passing length*sizeof(element) instead of just length to _d_array_slice_copy. --- gen/arrays.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gen/arrays.cpp b/gen/arrays.cpp index 59934b2f..27c75aac 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -364,12 +364,15 @@ void DtoArrayCopyToSlice(DSliceValue* dst, DValue* src) LLValue* sz1; LLValue* dstarr = get_slice_ptr(dst,sz1); + LLValue* srcarr = DtoBitCast(DtoArrayPtr(src), getVoidPtrType()); + const LLType* arrayelemty = DtoType(src->getType()->nextOf()->toBasetype()); + LLValue* sz2 = gIR->ir->CreateMul(DtoConstSize_t(getTypePaddedSize(arrayelemty)), DtoArrayLen(src), "tmp"); if (global.params.useAssert || global.params.useArrayBounds) { LLValue* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_slice_copy"); - gIR->CreateCallOrInvoke4(fn, dstarr, sz1, srcarr, DtoArrayLen(src)); + gIR->CreateCallOrInvoke4(fn, dstarr, sz1, srcarr, sz2); } else {