|
|
|
|
|
by gpderetta
529 days ago
|
|
> The act of writing a value of a different type tells the compiler that the lifetime of the previous object has ended. There's no special magic required. I think strictly speaking in C this is only true for anonymous memory, i.e. memory you got from some allocator-like function. So if your custom allocator gets its memory from malloc (or sbrk, or mmap), everything is fine, but, for example, you are allocating from a static char array, it is formally UB. In C++ you can use placement new to change the type of anything. |
|