summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-04-30 22:45:02 +0200
committerGitHub <noreply@github.com>2020-04-30 22:45:02 +0200
commit89be5be03e316193126cca637b326358489be908 (patch)
treec782a9688005aa92cdf8056bcec634eddb0a9b28
parent3d2459bdc0b6d6236a2cd9209ed81c965ee411a5 (diff)
downloadNim-89be5be03e316193126cca637b326358489be908.tar.gz
fixes #13698 [backport:1.2] (#14175)
-rw-r--r--lib/system/memory.nim4
-rw-r--r--tests/misc/trangechecks.nim5
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/system/memory.nim b/lib/system/memory.nim
index 8d190e5f9..50faa3d86 100644
--- a/lib/system/memory.nim
+++ b/lib/system/memory.nim
@@ -45,9 +45,9 @@ proc nimCmpMem*(a, b: pointer, size: Natural): cint {.compilerproc, nonReloadabl
       if d != 0: return d
       inc i
 
-proc nimCStrLen*(a: cstring): csize_t {.compilerproc, nonReloadable, inline.} =
+proc nimCStrLen*(a: cstring): int {.compilerproc, nonReloadable, inline.} =
   when useLibC:
-    c_strlen(a)
+    cast[int](c_strlen(a))
   else:
     var a = cast[ptr byte](a)
     while a[] != 0:
diff --git a/tests/misc/trangechecks.nim b/tests/misc/trangechecks.nim
index ac09e558c..e48b1272b 100644
--- a/tests/misc/trangechecks.nim
+++ b/tests/misc/trangechecks.nim
@@ -41,3 +41,8 @@ except OverflowDefect, RangeDefect:
   echo x
 
 echo expected == 4
+
+# bug #13698
+var
+  x45 = "hello".cstring
+  p = x45.len.int32