summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-07-27 14:32:56 +0200
committerGitHub <noreply@github.com>2021-07-27 14:32:56 +0200
commit6dc34757b6ed58aac723b409f084665b26a8afb1 (patch)
tree1523b96ae3800d1b9816b9877b2296738377684f /lib/system
parentc86f9590fb5ba6512ba33994fa0711341eb8524b (diff)
downloadNim-6dc34757b6ed58aac723b409f084665b26a8afb1.tar.gz
fixes #18579 (#18600)
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/arc.nim6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/system/arc.nim b/lib/system/arc.nim
index ed5e9f5ca..d66f4b997 100644
--- a/lib/system/arc.nim
+++ b/lib/system/arc.nim
@@ -207,10 +207,8 @@ proc nimDecRefIsLast(p: pointer): bool {.compilerRtl, inl.} =
 
 proc GC_unref*[T](x: ref T) =
   ## New runtime only supports this operation for 'ref T'.
-  if nimDecRefIsLast(cast[pointer](x)):
-    # XXX this does NOT work for virtual destructors!
-    `=destroy`(x[])
-    nimRawDispose(cast[pointer](x), T.alignOf)
+  var y {.cursor.} = x
+  `=destroy`(y)
 
 proc GC_ref*[T](x: ref T) =
   ## New runtime only supports this operation for 'ref T'.