summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-05-11 20:50:03 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-05-11 20:50:03 +0200
commit11d0f3f7ec99d0f738b40391cf58cfc9c05d62ed (patch)
treeb620d2377536a61b28ed6424323eed0f250e4806 /compiler
parent38040e76910639ef99d1685e2670140e408249da (diff)
downloadNim-11d0f3f7ec99d0f738b40391cf58cfc9c05d62ed.tar.gz
fixes #4034
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgtypes.nim1
-rw-r--r--compiler/cgen.nim3
2 files changed, 3 insertions, 1 deletions
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index da671940a..d4c11c20d 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -570,6 +570,7 @@ proc getTypeDescAux(m: BModule, typ: PType, check: var IntSet): Rope =
   of tyRange, tyEnum:
     let t = if t.kind == tyRange: t.lastSon else: t
     result = getTypeName(t)
+    if isImportedCppType(t): return
     idTablePut(m.typeCache, t, result)
     var size: int
     if firstOrd(t) < 0:
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 4f27a5a46..cd3117d4b 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -301,7 +301,8 @@ proc resetLoc(p: BProc, loc: var TLoc) =
 proc constructLoc(p: BProc, loc: TLoc, isTemp = false) =
   let typ = skipTypes(loc.t, abstractRange)
   if not isComplexValueType(typ):
-    linefmt(p, cpsStmts, "$1 = 0;$n", rdLoc(loc))
+    linefmt(p, cpsStmts, "$1 = ($2)0;$n", rdLoc(loc),
+      getTypeDesc(p.module, typ))
   else:
     if not isTemp or containsGarbageCollectedRef(loc.t):
       # don't use memset for temporary values for performance if we can