Path: utzoo!attcan!uunet!oddjob!ncar!ames!decwrl!sun!gorodish!guy
From: guy@gorodish.Sun.COM (Guy Harris)
Newsgroups: comp.lang.c
Subject: Re: is there anything wrong with return(n) from main?
Message-ID: <58690@sun.uucp>
Date: 1 Jul 88 07:21:17 GMT
References: <741@vsi.UUCP>
Sender: news@sun.uucp
Distribution: comp
Lines: 16

>      For some unknown reason, I have always felt uncomfortable
> doing a return(n) from main: I used exit(n) instead.  Can anybody
> think of any possible reason why a return is not a good idea?

Some implementations don't properly implement "return(n)" from "main".  SunOS's
C implementations did not do so from SunOS 2.0 to SunOS 3.5; they implement it
correctly in 4.0.  I seem to remember somebody claiming some other
implementation did not do so.

I think every S5 implementation from AT&T handled "return(n)" from "main"
correctly, as did 4.[23]BSD; this does not, of course, guarantee that any
particular implementation derived from either or both of those will do so
correctly.

ANSI C mandates it, so everybody's going to have to get with the program
eventually.