Well, first of all, it doesn’t matter. It says it’s not safe, don’t do it, period. I say this because I’ve seen too many people trying to play chicken with unsafe code.
Secondly, it depends. It might happen to work in certain environments with a specific configuration, but it’s absolutely not portable. So again, don’t do it.
Third, the actual problem alluded to there is that you can’t mix allocators. There’s no way for one allocator to manage memory allocated by a different allocator. If you transfer ownership of memory allocated by
Vec isn’t using
malloc (which it generally won’t be), then what happens when the
Vec goes to deallocate that memory is… well, anyone’s guess. Maybe your program crashes. If you’re lucky, you just leak that memory.