NULL is defined `((void *)0)`. Does (uintptr_t)NULL == 0? That is, does (uintptr_t)(void *)0 == (uintptr_t)0`?
@stevecheckoway Comparison of the form ptr == 0 is a special case in C++. But, that's not the same as (uintptr_t)pointer == 0.
-
-
@BRIAN_____@stevecheckoway NULL is not required to be void*. C99 §6.3.2.3/3. So ptr == 0 is also valid C. -
@sevenps@BRIAN_____ Yep. Entry in the C FAQ too http://c-faq.com/null/nullor0.html … -
@stevecheckoway@sevenps "It is only in pointer contexts that NULL and 0 are equivalent". (uintptr_t)(void *p)0 == 0 isn't pointer context -
@BRIAN_____@sevenps Agreed, but (uintptr_t)NULL == 0 also isn't a pointer context (in C++) so there, it should just be comparing 2 integers -
@stevecheckoway@sevenps Yes, exactly. But, is the integer value of (uintptr_t)NULL the value 0? -
@BRIAN_____@sevenps Hmm. Thinking further, I think#define NULL nullptr is valid, so maybe it's implementation-defined in C++ too. Fun! -
@stevecheckoway@BRIAN_____ Indeed, nullptr_t -> uintptr_t has the meaning of (void*)0 -> uintptr_t.
End of conversation
New conversation -
-
-
@BRIAN_____ I don't believe that's true. The C++ standard (working draft) says 0 or 0L are acceptable definitions but (void *)0 is not. -
@stevecheckoway ptr == 0 is operator==(void *, nullptr_t). (uintptr_t)ptr == 0 is operator==(uintptr_t, uintptr_t) -
@BRIAN_____ Fair enough!
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.