This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ordering of constructors
Neal Becker <ndbecker2@verizon.net> writes:
| Gabriel Dos Reis wrote:
|
| > Neal Becker <ndbecker2@verizon.net> writes:
| >
| > | Thanks for all the interesting responses to my question. Am I correct
| > | to summarize that there is currently no simple way to guarantee ordering
| > | of
| > | global constructors? (A couple of methods were suggested, but if I
| > | understand correctly, none are guaranteed to work?)
| >
| > There probably is no *general* method guaranteed to work. However,
| > you may want to look at your specific example whether it contains the
| > problematic cases raised in this thread.
| > Note that this is an issue only when you really have a dynamic
| > initialization.
| >
|
| By "dynamic initialization", do you mean there is an issue only for global
"dynamic initialization" is when you make a (non-trivial) call to a
function to initialize a non-local object.
| constructors in shared libs?
Actually I was thinking of the "reverse case": I was thinking that
there is an issue only if you link statically.
When linked against a shared (or dynamic) library, I thought GCC
implements the requirement I quoted earlier in this thread; but
apparently it does not (which I believe is a bug). The core issue
raised by Matt contains several scenarios which, after several
readings, make the possible combinations unclear to me (where I
thought they were clear).
| AFAICT, there is a problem even without considering shared libs. I tried
| what you suggested, I think, and it doesn't seem to work.
Yes, Daniel J. pointed out that it is not implemented by GCC. Sorry
for that confusion.
-- Gaby