Article View: comp.std.c
Article #5038Re: valueless return statement in non-void function
From: T.E.Dickey
Date: Sat, 20 Apr 1996 11:34
Date: Sat, 20 Apr 1996 11:34
29 lines
1672 bytes
1672 bytes
walter briscoe (walter@wbriscoe.demon.co.uk) wrote:
: I recently had trouble moving some K&R code to ISO C.
:
: Specifically, a function without a return statement was used to return a
: value with an implicit return at the } terminating the function.
...
: The obvious objection to such a statement is that it conflicts with
: prior art. I would answer that by making the implicit type of
: declarations void rather than int. That would allow less unreasonable
: prior art to port without complaint. I would have implicitly typed
: declarations deprecated in the next revision of the standard to
: facilitate their removal by a further revision.
Several years ago I ran into more than one instance of code that relied
on (some unspecified C compiler) that would return the last declared
variable if no return-value was given -- I assume the committe had that
one in mind, e.g.,
int foo()
{
int x = 4;
return; /* implictly returns 4 */
}
(of course I eradicated it from the code, but it would be interesting
to know whose compiler it was written for ;-)
--
Thomas E. Dickey
dickey@clark.net
Technical Details
Message-ID:
<4lai3u$5q2@clarknet.clark.net>Path:
arc1-ca.pugleaf.net!news.clark.net!not-for-mailReferences:
<829573502snz@wbriscoe.demon.co.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.clark.net!not-for-mail From: dickey@clark.net (T.E.Dickey) Newsgroups: comp.std.c Subject: Re: valueless return statement in non-void function Date: 20 Apr 1996 11:34:22 GMT Organization: Clark Internet Services, Inc., Ellicott City, MD USA Message-ID: <4lai3u$5q2@clarknet.clark.net> References: <829573502snz@wbriscoe.demon.co.uk> NNTP-Posting-Host: explorer.clark.net Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]