I have stumbled upon the following problem, if I compile (using Visual Studio 2010)
int main()
{
double* d_ptr = int(0);
if(d_ptr == nullptr)
cout << "I am a nullptr" << endl;
return 0;
}
I get the result "I am a nullptr"
This also works if I substitute the pointer assignment with:
double* ptr = (int) 0;
I would have expected both to fail since they both explicitly cast to integer which has not a pointer type. Could someone help me in understanding what is going on?
EDIT: Tried again with g++ and worked. Do not know what I did wrong the first time. Now I am only still troubled why it works in the first place.