summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-06-13 18:03:20 +0800
committerGitHub <noreply@github.com>2023-06-13 12:03:20 +0200
commit2e12d3e26bd39205a2aa61a8873173e579cbcb9e (patch)
tree49feccf26b3f8c56c781d9d74a9084b1f828b9ec /tests
parent5679f2b84c70dea131a5c6a0f633a714d6f41e36 (diff)
downloadNim-2e12d3e26bd39205a2aa61a8873173e579cbcb9e.tar.gz
fixes #22058; invalid free with {.noSideEffect.} in template (#22088)
Diffstat (limited to 'tests')
-rw-r--r--tests/arc/tmalloc.nim16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/arc/tmalloc.nim b/tests/arc/tmalloc.nim
new file mode 100644
index 000000000..1d72646c8
--- /dev/null
+++ b/tests/arc/tmalloc.nim
@@ -0,0 +1,16 @@
+discard """
+  matrix: "--mm:arc -d:useMalloc; --mm:arc"
+"""
+
+block: # bug #22058
+  template foo(): auto =
+    {.noSideEffect.}:
+      newSeq[byte](1)
+
+  type V = object
+    v: seq[byte]
+
+  proc bar(): V =
+    V(v: foo())
+
+  doAssert bar().v == @[byte(0)]