Subject: Re: NetBSD master CVS tree commits
To: None <christos@deshaw.com>
From: None <greywolf@defender.VAS.viewlogic.com>
List: current-users
Date: 06/04/1996 15:42:52
Someone wrote:

   | > Log Message:
   | > 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.
   | 
   | >From P1003.2/D11.2 section 3.9.5, p. 276:
   | 
   |  Exit_Status
   | 
   |  The exit status of a function definition shall be zero if the function
   |  was declared successfully; otherwise, it shall be greater than zero.  The
   |  exit status of a function invocation shall be the exit status of the last
   |  command executed by the function.

To which christos zoulas replied:

   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.

   christos

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);".  main() with no exit()
or explicit return statement seems to use the implicit return caused
by the closing brace; and it seems to treat it as "return;" for lack
of a better way to treat it.  I would expect "return;" to be treated
as a closing brace; i.e., return the last known lhs.  If all the
functions within were either declared or cast void, and there were
no automagic variable initializations, I would expect the behaviour
of "return;" to be undefined.  It would probably return a stack
address or something.

				--*greywolf;
--
Just because memory, disk and cpu speed are cheap is no excuse for
shoddy programming.