Article View: comp.std.c
Article #4728Re: atexit() and return from main()
From: Larry Jones
Date: Wed, 31 Jan 1996 15:58
Date: Wed, 31 Jan 1996 15:58
19 lines
1343 bytes
1343 bytes
In article <4emq9l$2fn@hammy.lonestar.org>, gordon@hammy.lonestar.org (Gordon Burditt) writes: > I claim that longjmp()ing out of an atexit function into main > causes undefined behavior because main() has already returned > (or, equivalently, called exit()) between the setjmp and > longjmp calls. > > In fact, calling exit() may not unwind the stack like returning > from main() does, so you might get away with it, but there's > no guarantee. Yes there is, sort of. A forthcoming compendium of Technical Corrigenda clarifies that returning from main and calling exit are not *completely* equivalent in that calling exit does *not* unwind the stack (at least not until so late in the processing that the program can not tell that it happened). ---- Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH 45150-2789 513-576-2070 larry.jones@sdrc.com You just can't ever be too careful. -- Calvin
Technical Details
Message-ID:
<4eo3i9$kbs@info1.sdrc.com>Path:
arc1-ca.pugleaf.net!sdrc.com!thor!scjonesReferences:
<4dhfja$j50@fg70.rz.uni-karlsruhe.de> <4diicg$i9e@lyra.csx.cam.ac.uk> <4emq9l$2fn@hammy.lonestar.org>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sdrc.com!thor!scjones From: scjones@thor.sdrc.com (Larry Jones) Newsgroups: comp.std.c Subject: Re: atexit() and return from main() Date: 31 Jan 1996 15:58:01 GMT Organization: SDRC Engineering Services Distribution: world Message-ID: <4eo3i9$kbs@info1.sdrc.com> References: <4dhfja$j50@fg70.rz.uni-karlsruhe.de> <4diicg$i9e@lyra.csx.cam.ac.uk> <4emq9l$2fn@hammy.lonestar.org> NNTP-Posting-Host: thor.sdrc.com