Hello, I was trying out 
[ASAN](https://github.com/google/sanitizers/wiki/AddressSanitizer) with a 
minimal example:
    
    
    import os, strutils, algorithm
    
    var
      data: array[1000, int]
    
    proc main: int =
      fill data, -1
      let idx = parseInt(paramStr(1))
      result = data[idx + 100]
    
    echo main()
    
    
    Run

Compiled with `nim c --panics:on --gc:arc -d:useMalloc -t:"-fsanitize=address" 
-l:"-fsanitize=address" -d:danger -g test.nim` Compile and links just fine 
(`gcc-libs` are indeed installed in my system, for example `ThreadSanitizer` 
works as expected).

When I try to give it faulty output:

`./test 1000`

outputs `0`, without an asan report. Similarly this example triggers no 
warnings:
    
    
    type
      Array = object
        data: ptr UncheckedArray[int]
    
    proc `=destroy`*(x: var Array) =
      if x.data != nil:
        dealloc(x.data)
    
    proc init(x: var Array) =
      x.data = cast[typeof(x.data)](alloc(1000 * sizeof(int)))
    
    proc main =
      var
        arr: Array
      
      echo arr.data[0]
    
    main()
    
    
    Run

Reply via email to