tlvalueconv.nim 542 B

123456789101112131415161718192021222324252627282930313233
  1. discard """
  2. matrix: "--gc:refc; --gc:arc"
  3. """
  4. # bug #14160
  5. type
  6. TPassContext = object of RootObj
  7. PPassContext = ref TPassContext
  8. PCtx = ref object of TPassContext
  9. a: int
  10. ModuleGraph = object
  11. vm: RootRef
  12. proc main() =
  13. var g = ModuleGraph(vm: new(Pctx))
  14. PCtx(g.vm) = nil #This generates invalid C code
  15. doAssert g.vm == nil
  16. main()
  17. # bug #14325
  18. proc main2() =
  19. var g = ModuleGraph(vm: new(Pctx))
  20. PPassContext(PCtx(g.vm)) = nil #This compiles, but crashes at runtime with gc:arc
  21. doAssert g.vm == nil
  22. main2()