|
|
|
|
|
by 0xcde4c3db
3453 days ago
|
|
> if P does not point to valid memory, then dereferencing it is UB IIRC, simply making P point to anything other than an object or 1 past the end of an array is already UB. I suspect that this is because some architectures have dedicated address registers and can take an exception when an invalid address is loaded/calculated instead of doing it when the memory access happens. |
|
I don't think this is true in the strict sense you're describing it. Certainly forming a null pointer isn't UB as I understand it, only dereferencing one.