diff --git a/gen/arrays.cpp b/gen/arrays.cpp index 38c3360189..9f998a02ed 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -234,8 +234,13 @@ void DtoArraySetAssign(Loc& loc, DValue *array, DValue *value, int op) assert(array && value); assert(op != TOKblit); - LLValue *ptr = DtoArrayPtr(array); - LLValue *len = DtoArrayLen(array); + LLValue* ptr = DtoArrayPtr(array); + LLValue* len = DtoArrayLen(array); + // The count parameter is of type int but len is of type size_t. + // If size_t is not int then truncated the value. + LLType* intType = LLType::getInt32Ty(gIR->context()); + if (len->getType() != intType) + len = gIR->ir->CreateTrunc(len, intType); LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, op == TOKconstruct ? "_d_arraysetctor" : "_d_arraysetassign"); LLValue* args[] = { diff --git a/gen/runtime.cpp b/gen/runtime.cpp index ce5b498b79..fd1acd6117 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -629,7 +629,7 @@ static void LLVM_D_BuildRuntimeModule() } // void* _d_arraysetassign(void* p, void* value, int count, TypeInfo ti) - // void* _d_arraysetctor(void* p, void* value, size_t count, TypeInfo ti) + // void* _d_arraysetctor(void* p, void* value, int count, TypeInfo ti) { llvm::StringRef fname("_d_arraysetassign"); llvm::StringRef fname2("_d_arraysetctor");