From 62b9dcb8dbc46df654a900f434f9cbfbdd67e556 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 30 Apr 2020 22:45:02 +0200 Subject: [PATCH] fixes #13698 [backport:1.2] (#14175) (cherry picked from commit 89be5be03e316193126cca637b326358489be908) --- lib/system/memory.nim | 4 ++-- tests/misc/trangechecks.nim | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/system/memory.nim b/lib/system/memory.nim index 8d190e5f9d..50faa3d862 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 2c6f0f66d3..4266e6e4f3 100644 --- a/tests/misc/trangechecks.nim +++ b/tests/misc/trangechecks.nim @@ -41,3 +41,8 @@ except OverflowError, RangeError: echo x echo expected == 4 + +# bug #13698 +var + x45 = "hello".cstring + p = x45.len.int32