19 ms·
Note that (void *)0 is always NULL, as mandated by the standard. But, to address the content of your comment: defined behavior at runtime is not necessarily go
by saagarjha 6y ago
Note that (void *)0 is always NULL, as mandated by the standard.
But, to address the content of your comment: defined behavior at runtime is not necessarily good behavior at runtime. Defining signed integer overflow to wrap, for example, is probably a bad idea, because this is rarely the intent of the code. Having all such operations trap might be a good idea, but now you're going to get the same "stop breaking my working programs" people angry at you.
- rndgermandude 6y agoYes, thankfully at least with NULL they didn't fall into the legacy trap and messed up the standard with non-zero NULL that some machines before have been kind of using. >Defining signed integer overflow to wrap, for example, is probably a bad idea I wouldn't call it great behavior, but it's at least what most people expect will happen, and most people will be able to understand what's going on, and it's fast on most systems that matter. However, it's still undefined behavior. Just codifying overflows to be wrapping, would therefore be an improvement in my opinion, at least over what we have today.
- gpderetta 6y agoI would say that most people expect it not to happen. If they really had to mandate a behavior, it should be to trap.
- account42 6y ago> Note that (void *)0 is always NULL, as mandated by the standard. Also note that this is distinct from the memory representation of (void *)0 being all 0 bits, which is explicitly not mandated.