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.


On Fri, Jan 29, 2010 at 08:32:35PM +0000, Andy Koppe wrote:
>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.

Actually, it really isn't if gcc is calling atexit under the hood since
that muddies the waters considerably.

cgf

--
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]