I know what this message means, I just wondered why it is not an error message, but just a warning?
What happens in this case? For example, suppose I have a function
int f()
{
}
and what happens when I call it?
Does the compiler adds returning of “non-initialized” int in this case?
Or the missing return could cause stack corruption?
Or it’s (absolutely) undefined behavior ?
Tested with gcc 4.1.2 and 4.4.3
EDIT: Reading the answers I understand one thing, reading the comments – another..
OK, let’s summarize: it’s undefined behavior. Then, this means, that it is possible to result in stack corruption, right? (it even means, that my computer may start throwing rotten tomatoes over me through the mic jack, screaming – “what have you done???”).
But if so, then why the top answer here says, that stack corruption can’t happen and, in the same time, that the behaviour is undefined?
And undefined in respect to? The caller, that tries to use the “not returned value”, or just the end of the function is undefined, if it must return value, but it doesn’t?
Or it’s not undefined behavior, and just the user, who tries to use the value (that is not returned, d’oh!) will “receive” undefined value? In other words – just some garbage value and nothing more can happen?
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++: