No, C ++ never required all control paths to return a value. It is valid for C ++ 11 and C ++ 03 (syntactically).
Some compilers can detect most situations where you do not have enough return, but diagnostics are not required. Most of them will not issue a diagnosis if at least the control path returns.
Regardless, this is UB.
source share