diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 3590a17bcb..1366caab30 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -245,6 +245,9 @@ proc isImportedCppType(t: PType): bool = proc isOrHasImportedCppType(typ: PType): bool = searchTypeFor(typ.skipTypes({tyRef}), isImportedCppType) +proc hasNoInit(t: PType): bool = + result = t.sym != nil and sfNoInit in t.sym.flags + proc getTypeDescAux(m: BModule; origTyp: PType, check: var IntSet; kind: TypeDescKind): Rope proc isObjLackingTypeField(typ: PType): bool {.inline.} = diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 043c014a21..e4ba416145 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -532,7 +532,7 @@ proc constructLoc(p: BProc, loc: var TLoc, isTemp = false) = linefmt(p, cpsStmts, "$1 = ($2)0;$n", [rdLoc(loc), getTypeDesc(p.module, typ, descKindFromSymKind mapTypeChooser(loc))]) else: - if not isTemp or containsGarbageCollectedRef(loc.t): + if (not isTemp or containsGarbageCollectedRef(loc.t)) and not hasNoInit(loc.t): # don't use nimZeroMem for temporary values for performance if we can # avoid it: if not isOrHasImportedCppType(typ):