Static initialisation

Mike Harrold mharrold@cas.org
Sun Nov 10 20:10:00 GMT 2002


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



More information about the Gcc-bugs mailing list