Reinterpret to non bits type

Right, this right there is what’ll break down on the julia side, without reaching for Ptr or RefArray yourself or having it be Any[]. To the compiler this may not be a safe operation, especially since a priori you don’t know whether the element type is stored inline or not, which you’d have to branch on in your reinterpreting/casting code. As such, it only works in this contained example because you’ve specified an int* and float* - keeping this as generic in julia as you’ve described would require more or less a void* input in C, I think.

I think this problem only comes from wanting to reuse the memory for potentially differently typed “buffers”, across different sorting routines, without knowing the types of the elements ahead of time. Do you have an example for such a sorting routing I could take a look at, to maybe help translate it to julia & integrate it with this approach (or finding a suitable replacement)?

1 Like