This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dlclose not calling destructors of static variables.


Christopher Faylor:
> Andrew West:
>>O.k. I'll check out the changes on Monday, but one minor point.
>>Shouldn't the atexit stuff be run after all the destructors have run?
>
> Not if the output from the linux version of your program is to be
> believed. ÂI originally had the atexit stuff run after the dtors and saw
> this:
>
> testlib:: stop
> TestClass::~TestClass()
>
> Putting the atexit stuff first reversed the order, making it match
> linux.

The C++ standard requires static destructors and atexit functions to
be executed in the opposite order that the corresponding constructors
were invoked and the atexit functions were registered. Since atexit()
may be called from static constructors, there should theoretically be
a single stack for destructors and atexit functions. But if that's not
practical, invoking the atexit stuff first is a fairly decent
approximation.

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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