This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: What should -Wmissing-noreturn do with "int main(){exit(0);}" ?
- To: Jason Merrill <jason@cygnus.com>
- Subject: Re: What should -Wmissing-noreturn do with "int main(){exit(0);}" ?
- From: Jamie Lokier <egcs@tantalophile.demon.co.uk>
- Date: Sun, 15 Aug 1999 23:40:50 +0200
- Cc: "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu>, rth@cygnus.com, egcs-patches@egcs.cygnus.com, egcs@egcs.cygnus.com
- References: <199908142314.TAA17260@caip.rutgers.edu> <u9pv0oonf2.fsf@yorick.cygnus.com>
Jason Merrill wrote:
> If it doesn't return, it doesn't return. Calling exit bypasses the return
> from main. It doesn't make much sense to me, stylistically; I'd suggest
> changing the exit call to a return statement, but declaring main noreturn
> would also work.
Exiting makes a lot of sense to me. Do you want main full of returns
while other code uses exit for the same thing? If there were such a
thing as enum exit_status_t, maybe, but there isn't so return invites a
few bugs when cutting & pasting.
-- Jamie