This is the mail archive of the gcc-bugs@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]

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


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