diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 5600f6842dd5..367030f9f538 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -254,11 +254,11 @@ proc genGenericAsgn(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) = if (dest.storage == OnStack and p.config.selectedGC != gcGo) or not usesWriteBarrier(p.config): let rad = addrLoc(p.config, dest) let ras = addrLoc(p.config, src) - let rd = rdLoc(dest) + let td = getTypeDesc(p.module, dest.t) p.s(cpsStmts).addCallStmt(cgsymValue(p.module, "nimCopyMem"), cCast(CPointer, rad), cCast(CConstPointer, ras), - cSizeof(rd)) + cSizeof(td)) else: let rad = addrLoc(p.config, dest) let ras = addrLoc(p.config, src) @@ -2553,7 +2553,7 @@ proc genCast(p: BProc, e: PNode, d: var TLoc) = p.s(cpsLocals).addField(name = "source", typ = srcTyp) p.s(cpsLocals).addCallStmt(cgsymValue(p.module, "nimZeroMem"), cAddr("LOC" & lbl), - cSizeof("LOC" & lbl)) + cIntValue(destsize)) else: p.s(cpsLocals).addVarWithType(kind = Local, name = "LOC" & lbl): p.s(cpsLocals).addUnionType(): diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index ed840a97a8fa..af389fa8c492 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -161,13 +161,13 @@ proc genVarTuple(p: BProc, n: PNode) = typ = NimBool, initializer = NimFalse) for curr in hcrGlobals: - let rc = rdLoc(curr.loc) + let tc = getTypeDesc(p.module, curr.loc.t) p.s(cpsLocals).addInPlaceOp(BitOr, NimBool, hcrCond, cCall("hcrRegisterGlobal", getModuleDllPath(p.module, n[0].sym), '"' & curr.loc.snippet & '"', - cSizeof(rc), + cSizeof(tc), curr.tp, cCast(ptrType(CPointer), cAddr(curr.loc.snippet)))) @@ -434,11 +434,11 @@ proc genSingleVar(p: BProc, v: PSym; vn, value: PNode) = if forHcr and targetProc.blocks.len > 3 and v.owner.kind == skModule: # put it in the locals section - mainly because of loops which # use the var in a call to resetLoc() in the statements section - let rv = rdLoc(v.loc) + let tv = getTypeDesc(p.module, v.loc.t) p.s(cpsLocals).addCallStmt("hcrRegisterGlobal", getModuleDllPath(p.module, v), '"' & v.loc.snippet & '"', - cSizeof(rv), + cSizeof(tv), traverseProc, cCast(ptrType(CPointer), cAddr(v.loc.snippet))) # nothing special left to do later on - let's avoid closing and reopening blocks @@ -449,12 +449,13 @@ proc genSingleVar(p: BProc, v: PSym; vn, value: PNode) = # be able to re-run it but without the top level code - just the init of globals var hcrInit = default(IfBuilder) if forHcr: + let tv = getTypeDesc(p.module, v.loc.t) startBlockWith(targetProc): hcrInit = initIfStmt(p.s(cpsStmts)) initElifBranch(p.s(cpsStmts), hcrInit, cCall("hcrRegisterGlobal", getModuleDllPath(p.module, v), '"' & v.loc.snippet & '"', - cSizeof(rdLoc(v.loc)), + cSizeof(tv), traverseProc, cCast(ptrType(CPointer), cAddr(v.loc.snippet)))) if value.kind != nkEmpty and valueAsRope.len == 0: