What (actually) happens, when a function with the warning “control reaches end of non-void function” is called?

A: No, the missing return would not cause stack corruption

A: Yes, the behavior would be “undefined” if the caller tried to read and/or use the (undefined!) return value.

PS:

Here’s a citation for C++:

C++03 ยง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.

Leave a Comment