summary refs log tree commit diff stats
path: root/tests/ccgbugs/tlvalueconv.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ccgbugs/tlvalueconv.nim')
-rw-r--r--tests/ccgbugs/tlvalueconv.nim32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ccgbugs/tlvalueconv.nim b/tests/ccgbugs/tlvalueconv.nim
new file mode 100644
index 000000000..b2cb11eef
--- /dev/null
+++ b/tests/ccgbugs/tlvalueconv.nim
@@ -0,0 +1,32 @@
+discard """
+  matrix: "--gc:refc; --gc:arc"
+"""
+
+# bug #14160
+
+type
+  TPassContext = object of RootObj
+  PPassContext = ref TPassContext
+
+  PCtx = ref object of TPassContext
+    a: int
+
+  ModuleGraph = object
+    vm: RootRef
+
+proc main() =
+  var g = ModuleGraph(vm: new(Pctx))
+  PCtx(g.vm) = nil #This generates invalid C code
+  doAssert g.vm == nil
+
+main()
+
+# bug #14325
+
+proc main2() =
+  var g = ModuleGraph(vm: new(Pctx))
+  PPassContext(PCtx(g.vm)) = nil #This compiles, but crashes at runtime with gc:arc
+  doAssert g.vm == nil
+
+main2()
+