Quote Originally Posted by nowshek
but the following code compiles and runs without error............
That is one possible outcome of undefined behaviour.

Suppose you murder your neighbour in cold blood. You are never caught. Does that mean that it was legal for you to murder your neighbour?