Consider following code:
#include <iostream>
int main()
{
int *a = 0, *b = 0;
std::cout << (a - b);
}
At ideone this code prints 0 as expected, but I'm not sure if it is well-defined behavior or not.
I wonder if (T*)0 - (T*)0
is well-defined or not? Is it guaranteed to be equal to 0
?
Is it same in C and C++? If not, what are the differences?
(Of course, T
is not void
nor std::nullptr_t
, because pointer arithmetic does not work for them.)