TITLE: registering functions with atexit (Newsgroup: comp.std.c++, 1 Dec 98) ALEXANDRESCU: "Andrei Alexandrescu" >The question is: say I register function > >void foo(); > >to be called by atexit. From within foo(), I call atexit() again and >register the function: > >void bar(); > >to be called. Will be bar() called? Clamage: Steve Clamage (stephen.clamage@sun.com) Neither the C nor the C++ standards define what happens after you register bar(). In fact, each is self-contradictory on the matter! The question was put to the C committee at their meeting last month, and I have been told informally that the next C standard will make the result undefined. The C++ committee has the question on their list of potential Defect Reports, and has yet to make a decision (on this or on any other DR -- it's too soon to consider them). I expect the C++ committee to declare the behavior to be undefined. In the mean time, I know of at least one implementation that crashes if you attempt to register a function with atexit once exit processing has begun. So don't do it.