3 ms·
I think even deriving the argument might invoke undefined behaviour here, but I'm not certain. If I understand correctly, it's undefined behaviour to do this:
by MaxBarraclough 5y ago
I think even deriving the argument might invoke undefined behaviour here, but I'm not certain.
If I understand correctly, it's undefined behaviour to do this:
int *ptr = (int*)42;
As, in order to avoid undefined behaviour, ptr should only be assigned a valid address of an int, or the 'address' one past the end of an array of int, or NULL (logical zero).
It's possible things are different when the type is void*, I'm not certain.
- tedunangst 5y agoMake it free(free) if you want it to be a valid pointer.