This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Static initialisation
- From: Mike Harrold <mharrold at cas dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 10 Nov 2002 23:10:52 -0500 (EST)
- Subject: Static initialisation
Hi,
Before I submit a bug report, I wanted to know if the following
behaviour is correct.
In a source module that contains static members of a class, the
initialisation and destruction of those members is done within
the static_initialization_and destruction function.
However, one of the (static) member functions of the class defines
a static const variable of a class type derived from std::string.
The initialisation of this variable registers the destruction
mechanism with atexit in order to destroy it.
Is this the correct behaviour?
The reason I ask is because this particular module is dynamically
loaded and unloaded using dlopen/dlclose. Naturally, when the
program terminates, the exit mechanism ends up calling the
destruction mechanism of the variable, but the code has already
been unloaded so I get a seg-fault.
Please let me know either way. If the behaviour is incorrect, I
will create a small test-case and submit a full bug report.
Thanks in advance,
/Mike