2 ms·
> what is wrong with NULL? One of the few advantages of ISO standardization is you can just read the associated papers to answer questions like this: https://w
by nickelpro 2y ago
> what is wrong with NULL?
One of the few advantages of ISO standardization is you can just read the associated papers to answer questions like this: https://wg21.link/p2312 https://wg21.link/p2312
The quick bullet points:
* Surprises when invoking a type-generic macro with a NULL argument.
* Conditional expressions such as (1 ? 0 : NULL) and (1 ? 1 : NULL) have different status depending how NULL is defined
* A NULL argument that is passed to a va_arg function that expects a pointer can have severe consequences. On many architectures nowadays int and void* have different size, and so if NULL is just 0, a wrongly sized argument is passed to the function.
- deleted 2y ago[deleted]