cstrings are untraced pointers. They cannot hold the ownership of a Nim string. When you assign `"Hey there C code! " & $rand(100)` (a string as a temporary object) to `result` (a cstring), the `string`'s life ends because its reference count is reduced to zero and is not increased, and as a result, it could be freed at any time. Your code might work because heap data might not be erased frequently, but it's still considered used-after-free.
- Calling Nim proc from C and handling the cstring (char array) retu... olwa
- Calling Nim proc from C and handling the cstring (char array)... Araq
- Calling Nim proc from C and handling the cstring (char ar... sls1005
