summary refs log tree commit diff stats
path: root/tests/arc/topenarray.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/arc/topenarray.nim')
-rw-r--r--tests/arc/topenarray.nim16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/arc/topenarray.nim b/tests/arc/topenarray.nim
index 67c512e4f..ba91666ba 100644
--- a/tests/arc/topenarray.nim
+++ b/tests/arc/topenarray.nim
@@ -68,3 +68,19 @@ block:
   doAssert foo(noBugConst) == expected
   let noBugSeq = @["0", "c", "a"]
   doAssert foo(noBugSeq) == expected
+
+block: # bug #20865
+  var p: pointer
+  var x: array[0, int]
+  # echo toOpenArray(x, 0, 1)[0] # Raises IndexDefect
+  doAssertRaises(IndexDefect):
+    echo toOpenArray(cast[ptr array[0, int]](p)[], 0, 1)[0] # Does not raise IndexDefect
+
+block: # bug #20987
+  var v: array[1, byte]
+
+  var p = cast[ptr array[0, byte]](addr v)
+
+  doAssertRaises(IndexDefect):
+    echo toOpenArray(p[], 1, 2)
+