functions that don't return

Chris Torek chris at umcp-cs.UUCP
Tue Oct 7 10:05:19 AEST 1986


In article <147 at bobkat.UUCP> pedz at bobkat.UUCP (Pedz Thing) writes:
>I think [the support library start-up code] should be the second
>choice, main(); exit(0);.  The reason is two fold.  First, unless
>a program specifically bombs off, it should exit with a happy status.
>Falling off the bottom of main I would not consider to be doing
>anything specific yet the return (and exit) value will be random.

But it is doing something specific: the close-brace, if reachable,
is equivalent to `return;'.  I doubt that anyone would argue that

	double foo() {
		return;
	}

is correct.  Is then

	int main(argc, argv) ... {
		...
		return;
	}

correct?

[The trick, of course, is that I have slipped in the keyword `int',
which cannot be found modifying main() in K&R.  On the other hand,
the use of exit() to enforce clean termination, and (not so
incidentally) make that last close-brace unreachable, is covered.]

>Second, with a random exit status, it makes the program much less
>usefull.  Make(1) will sometimes work and sometimes fail, etc.

Indeed.  So fix the program.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at mimsy.umd.edu



More information about the Comp.lang.c mailing list