From d89ed548f7c346dab1328fa87c9eadf8b2c70a75 Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 30 Apr 2020 20:09:25 +0200 Subject: [PATCH] fixes #13698 [backport:1.2] --- 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 8d190e5f9d61e..50faa3d862902 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 ac09e558c0561..e48b1272b1d4c 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