This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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]

Attribute destructor function and C++ destructors


Hi,

Just wanted to confirm whether the use of global static variables are allowed in attribute
constructor(foo_init)/destructor(foo_fini).

I have a shared library that in foo_init reads a file and writes to static global variables.
In foo_fini it writes that information (possibly modified) back to the file.  Now under
gcc 4.0.1 (from MandrivaLinux 2006) I didn't see any issues.  In gcc 4.1.1 (from
MandrivaLinux 2007) I've found the destructors for the globals are run before foo_fini,
causing problems for C++ objects (std::string in my case).

This does imply to me that if C++ globals are invalid then technically all globals are
invalid.  So wanted to ask if this is a bug and/or what is the correct way to do this?

Regards,
Simon

-- 

Search for products and services at: 
http://search.mail.com


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