Doing this:
union{
int * integer;
char * character;
} u;
u.integer = new int;
delete u.character;
u.integer = new int[5];
delete [] u.character;
I assume this wouldn't work if any of these types have non trivial destructors, but is this ok?
This doesn't work in any case, if we assume work means having well-defined behavior rather than appearing to work (i.e. not crashing)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With