tmissingderef.nim 661 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. discard """
  2. output: '''[10, 0, 0, 0, 0, 0, 0, 0]
  3. 255
  4. 1 1
  5. 0.5'''
  6. """
  7. # bug #1181
  8. type
  9. TFoo = object
  10. x: int32
  11. proc mainowar =
  12. var foo: TFoo
  13. foo.x = 0xff
  14. var arr1 = cast[ptr array[4, uint8]](addr foo)[] # Fails.
  15. echo arr1[when cpuEndian == littleEndian: 0 else: 3]
  16. var i = 1i32
  17. let x = addr i
  18. var arr2 = cast[ptr array[4, uint8]](x)[] # Fails.
  19. echo arr2[when cpuEndian == littleEndian: 0 else: 3], " ", i
  20. # bug #1715
  21. var a: array[2, float32] = [0.5'f32, 0.7]
  22. let p = addr a
  23. var b = p[]
  24. echo b[0]
  25. # bug 2963
  26. var
  27. a = [8, 7, 3, 10, 0, 0, 0, 1]
  28. b = [10, 0, 0, 0, 0, 0, 0, 0]
  29. ap = addr a
  30. ap[] = b
  31. echo repr(a)
  32. mainowar()