File: tthreadheapviolation1.nim

package info (click to toggle)
nim 1.4.6%2Breally1.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 936,800 kB
  • sloc: sh: 17,201; ansic: 4,767; makefile: 856; python: 407; sql: 298; asm: 141; xml: 13
file content (18 lines) | stat: -rw-r--r-- 369 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
discard """
  errormsg: "'horrible' is not GC-safe"
  line: 11
  cmd: "nim $target --hints:on --threads:on $options $file"
"""

var
  global: string = "test string"
  t: Thread[void]

proc horrible() {.thread.} =
  global = "string in thread local heap!"
  var x = global
  var mydata = (x, "my string too")
  echo global

createThread[void](t, horrible)
joinThread(t)