t5648.nim 426 B

123456789101112131415161718192021222324252627282930313233
  1. discard """
  2. output: '''
  3. ptr Foo
  4. '''
  5. joinable: false
  6. """
  7. # not joinable because it causes out of memory with --gc:boehm
  8. # issue #5648
  9. import typetraits
  10. type Foo = object
  11. bar: int
  12. proc main() =
  13. var f = create(Foo)
  14. f.bar = 3
  15. echo f.type.name
  16. discard realloc(f, 0)
  17. var g = Foo()
  18. g.bar = 3
  19. var
  20. mainPtr = cast[pointer](main)
  21. mainFromPtr = cast[typeof(main)](mainPtr)
  22. doAssert main == mainFromPtr
  23. main()