Assigning a reference by dereferencing a NULL pointer
int& fun() { int * temp = NULL; return *temp; } In the above method, I am trying to do the dereferencing of a NULL pointer. When I call this function it does not give exception. I found when return type is by reference it does not give exception if it is by value then it does. Even when dereferencing of NULL pointer is assinged to reference (like the below line) then also it does not give. int* temp = NULL: int& temp1 = *temp; Here my question is that does not compiler do the dereferencing in case of reference? Dereferencing a null pointer is Undefined Behavior . An Undefined Behavior means