[omniORB] omniInitialRefLister
Bruce Visscher
visschb@rjrt.com
Thu, 15 Jul 1999 11:57:36 -0400
David.Chung@USPTO.GOV wrote:
>
> If I remember correctly, static objects are supposed to be destroyed
> in the reverse order
> that the static objects were originally created.
> (at least that is what is supposed to happen under ANSI C++ standard).
>
This is true only within each (singular) translation unit. There is no
guarantee between translation units. If you have a singleton in another
translation unit that depends (directly or indirectly) on this you may
be out of luck.
> The point here is that if omniORB properly orchestrates the
> static object creation, the destruction of those objects also should be
> orderly
> (in the "reverse" order). If the destruction is not done in the proper
> order even
> though the creation of those objects is orderly, then the problem may
> lie with the compiler/linker.
>
Actually, I have often wondered about this. The advice I've most often
seen is to prefer function scope static over file, class or namespace
scope for singletons.
I seem to recall that there was a comment in one of the .cc files in the
omniORB2 library implementation that indicated that this approach (using
function scope static for singletons) was found to be problematic on
some platforms (it was a long time ago and I may be reading more into it
than was intended). Is this correct?
Bruce