summary refs log tree commit diff stats
path: root/tests/ccgbugs
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-10-26 12:23:37 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-10-26 12:23:37 +0200
commit129a599cd677e6682ddb899b92c785c205ed5e2e (patch)
treeff9e11d6a067b35263870ed7d74ac94412f82d0f /tests/ccgbugs
parentc4dcbb45f4cbc6e962ea841d5656156aa55eff95 (diff)
downloadNim-129a599cd677e6682ddb899b92c785c205ed5e2e.tar.gz
fixes #6422
Diffstat (limited to 'tests/ccgbugs')
-rw-r--r--tests/ccgbugs/tbug1081.nim19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/ccgbugs/tbug1081.nim b/tests/ccgbugs/tbug1081.nim
index 71628feec..c9a9e6aa4 100644
--- a/tests/ccgbugs/tbug1081.nim
+++ b/tests/ccgbugs/tbug1081.nim
@@ -2,7 +2,8 @@ discard """
   output: '''1
 0
 0
-0'''
+0
+x = [a, b, c, 0, 1, 2, 3, 4, 5, 6] and y = [a, b, c, 0, 1, 2, 3, 4, 5, 6]'''
 """
 
 proc `1/1`() = echo(1 div 1)
@@ -15,3 +16,19 @@ let `1/4` = 1 div 4
 `1/2`()
 echo `1/3`
 echo `1/4`
+
+# bug #6422
+
+proc toCharArray1(N : static[int], s: string): array[N, char] =
+  doAssert s.len <= N
+  let x = cast[ptr array[N, char]](s.cstring)
+  x[]
+
+proc toCharArray2(N : static[int], s: string): array[N, char] =
+  doAssert s.len <= N
+  let x = cast[ptr array[N, char]](s.cstring)
+  result = x[]
+
+let x = toCharArray1(10, "abc0123456")
+let y = toCharArray2(10, "abc0123456")
+echo "x = ", $x, " and y = ", $y