This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: global {con,de}structors, atexit & friends
- To: drepper at cygnus dot com
- Subject: Re: global {con,de}structors, atexit & friends
- From: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Sat, 25 Jul 1998 16:14:45 +0200
- CC: egcs at cygnus dot com
- References: <r290ljqcw2.fsf@happy.cygnus.com>
> - do you agree?
> - do we miss something?
As I said before, I like this. After thinking about it, I feel you
miss some points:
- The __DYNAMIC_DTOR_LIST__, is it per shared object, or global (per
process). If per shared object (i.e. one for each shared library),
how do you handle the interleaving of destructors across shared
objects? I.e.
void f(){ //a.so
static A x;
}
void g(){ //b.so
static B x;
f();
static B y;
}
This could be solved by making the DTOR_LIST a list and not an
array. Of course, inserting an element in the front of the chain
is more expensive in a MT environment.
- How do you handle static objects initialized during global
constructors? I.e
void f();
struct A{
A(bool b){
if(b)f();
}
~A(){side_effects();}
};
A global(true);
void f(){
static A lokal(false);
}
A another(false);
To solve this, even the globals would need slots in .dtor.dynamic.
Martin