This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: What should -Wmissing-noreturn do with "int main(){exit(0);}" ?


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]