[Solved] Why does my C++ program crash when I forget the return statement, rather than just returning garbage?

Forgetting the return value results in the control flow reaching the end of a function. The C and C++ standards both describe this case. Note that main is an exception to this case and is described separately. Flowing off the end of a function is equivalent to a return with no value; this results in … Read more