From ccd24cc09a04ff35a7699f7b0d3140288f151200 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Sat, 3 Sep 2022 05:32:40 +0800 Subject: [PATCH] Use typed gep in `arrays.cpp` (#4098) --- gen/arrays.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gen/arrays.cpp b/gen/arrays.cpp index a246d3526d..cb79aebb38 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -808,9 +808,10 @@ void DtoCatAssignElement(const Loc &loc, DValue *array, Expression *exp) { // Assign to the new last element. LLValue *newLength = DtoArrayLen(array); LLValue *ptr = DtoArrayPtr(array); + LLType *ptrty = i1ToI8(DtoType(array->type->nextOf())); LLValue *lastIndex = gIR->ir->CreateSub(newLength, DtoConstSize_t(1), ".lastIndex"); - LLValue *lastElemPtr = DtoGEP1(ptr, lastIndex, ".lastElem"); + LLValue *lastElemPtr = DtoGEP1(ptrty, ptr, lastIndex, ".lastElem"); DLValue lastElem(arrayType->nextOf(), lastElemPtr); DtoAssign(loc, &lastElem, expVal, EXP::blit); callPostblit(loc, exp, lastElemPtr);