Unix Technical Forum

Re: return or exit at end of main()?

This is a discussion on Re: return or exit at end of main()? within the mailing.openbsd.tech forums, part of the OpenBSD category; --> Marc Espie wrote: > *sigh*. I know what our C++ compiler currently does. Remember ? I'm kind > of ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 08:50 AM
Neil Conway
 
Posts: n/a
Default Re: return or exit at end of main()?

Marc Espie wrote:
> *sigh*. I know what our C++ compiler currently does. Remember ? I'm kind
> of maintaining it. This is a somewhat rhethorical question: we do something,
> but is this the *right* thing from a standards point of view, or just what
> buggy behavior we currently happen to have.


My copy of the C++ spec (ISO/IEC 14882:1998(E)) states WRT exit()
behavior (18.3.8):

"First, objects with static storage duration are destroyed and functions
registered with atexit are called. Objects with static storage duration
are destroyed in the reverse order of the completion of their
constructor. (Automatic objects are not destroyed as a result of calling
exit().)"

which references a footnote that adds:

"Objects with automatic storage duration are all destroyed in a program
whose function main() contains no automatic objects and executes the
call to exit(). Control can be transferred to directly to such a main()
by throwing an exception that is caught in main()."

-Neil

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:56 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com