From 3f4b9971fc098e05a75f0d830f2f04e1dc814668 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 3 Nov 2019 09:46:33 +0100 Subject: [PATCH] newruntime: only check for dangling refs when 'owned ref T' support is enabled --- lib/core/runtime_v2.nim | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/core/runtime_v2.nim b/lib/core/runtime_v2.nim index fe4bf37bf..aa2511ce4 100644 --- a/lib/core/runtime_v2.nim +++ b/lib/core/runtime_v2.nim @@ -71,13 +71,14 @@ proc nimIncRef(p: pointer) {.compilerRtl, inl.} = proc nimRawDispose(p: pointer) {.compilerRtl.} = when not defined(nimscript): - when hasThreadSupport: - let hasDanglingRefs = atomicLoadN(addr head(p).rc, ATOMIC_RELAXED) != 0 - else: - let hasDanglingRefs = head(p).rc != 0 - if hasDanglingRefs: - cstderr.rawWrite "[FATAL] dangling references exist\n" - quit 1 + when defined(nimOwnedEnabled): + when hasThreadSupport: + let hasDanglingRefs = atomicLoadN(addr head(p).rc, ATOMIC_RELAXED) != 0 + else: + let hasDanglingRefs = head(p).rc != 0 + if hasDanglingRefs: + cstderr.rawWrite "[FATAL] dangling references exist\n" + quit 1 when defined(useMalloc): c_free(p -! sizeof(RefHeader)) else: