Subject: Re: NetBSD master CVS tree commits
To: None <current-users@NetBSD.ORG>
From: der Mouse <mouse@Collatz.McRCIM.McGill.EDU>
List: current-users
Date: 06/05/1996 20:11:08
>>> Fix PR/2504: return with no args returns 0 instead of the return
>>> value of the previous command in functions
>> I think this PR was in error. [...]

> The PR/ and the fix are correct I think. My commit comment leaves a
> lot to be desired... It used to always return 0, and now it returns
> the value of the previous command.

[in other words, the commit comment describes the problem rather than
the fix.]

> Sigh.  Here we go again with YASD.

> I have NEVER trusted a simple "return;" to explicitly return zero,
> not since main(){printf("hello, world\n");} exited with a status of
> 28 the last time I failed to explicitly say "exit(0);".

Uh, greywolf, this is sh they're talking about, not C.

> I would expect "return;" to be treated as a closing brace; i.e.,
> return the last known lhs.  [...]

[Note: I am now talking about C, not sh.]

Falling off the end of a function is equivalent to a return statement
with no expression...which is NOT equivalent to returning "the last
known lhs".  It just happens to end up that way in a common cases.
Returning with no expression from a function with a non-void return
type is an error; it either produces "demons fly out of your nose"
undefined behavior or the value returned is undefined, I forget which.

					der Mouse