The library I am wrapping, chose for whatever reason, instead of creating arrays of Vector3, to allocate an array of size 3*sizeof(cfloat). I am having trouble writing a reinterpreting cast that will work with a var return type.
type
  Mesh = object
    ..
    vertexCount: int32
    normals: ptr UncheckedArray[float32]
proc `[]`*(x: var Mesh, i: int32): var Vector3 =
  result = cast[ptr Vector3](Mesh(x).normals[i*sizeof(Vector3)].addr)[]
Crashes with SIGSEGV: Illegal storage access. What is the correct way to write this?