status-im / nim-faststreams

Nearly zero-overhead input/output streams for Nim
Apache License 2.0
125 stars 11 forks source link

don't even notionally access element 0 of 0-length openArray #26

Closed tersec closed 2 years ago

tersec commented 2 years ago

Conceptually, this is attempting to get the base address of the openArray.

I checked that it so far seemed to always return the same results, where applicable, as the unsafeAddr mem[0] approach, and

proc baseAddr*[T](x: openArray[T]): pointer = cast[pointer](x)

from nim-stew, while using pointer rather than ptr byte, suggests that this should work as well.

It compiles to

head = ((NU8*) (mem));

which is correct, as well.