2 ms·
An integer constant expression with value 0 is guaranteed to convert to a null pointer (in fact, the "null pointer constant" was traditionally defined to be pre
by jcranmer 2y ago
An integer constant expression with value 0 is guaranteed to convert to a null pointer (in fact, the "null pointer constant" was traditionally defined to be precisely that). But an integer with value 0 that's not an integer constant expression can potentially be legally a pointer value which is not a null pointer. Which means, confusingly, that it is legal for this to print true:
if (((void*)0) != (void*)(0, 0))
puts("true");
(Conversion between integers and pointers is a lot less well-specified than many people suspect, and that's before people start pondering provenance.)