It's undefined behaviour:
[C++11: 6.6.3/2]:
[..] Flowing off the end of a function is equivalent to a return
with no value; this results in undefined behavior in a value-returning function.
It compiles because:
- the compiler is not required to diagnose it;
- diagnosing this is not always trivial, so your compiler doesn't bother;
- C++ is a "do it yourself" language.