tgcsafe3.nim 466 B

12345678910111213141516171819202122
  1. discard """
  2. errormsg: "'myproc' is not GC-safe as it accesses 'global_proc' which is a global using GC'ed memory"
  3. line: 12
  4. cmd: "nim $target --hints:on --threads:on $options $file"
  5. """
  6. var useGcMem = "string here"
  7. var global_proc: proc(a: string) {.nimcall.} = proc (a: string) =
  8. echo useGcMem
  9. proc myproc(i: int) {.gcsafe.} =
  10. when false:
  11. if global_proc != nil:
  12. echo "a"
  13. if isNil(global_proc):
  14. return
  15. global_proc("ho")
  16. myproc(0)