Boost logo

Boost :

Subject: Re: [boost] Need second opions from some threading / objectcreationexperts...
From: Robert Ramey (ramey_at_[hidden])
Date: 2011-05-15 16:24:18

John Maddock wrote:

> The thing I'm concerned about is this:
> * The code currently relies on a call to a function in a static
> object to force that object to be instantiated and initialize the
> singleton, but: * Once compiler optimizations are turned on, that
> function call will be optimized away to a no-op.
> * There's now no code that's using the global object.
> * A clever linker says "hey we don't need this anymore" and removes
> it from the program image, so:
> * The singleton no longer gets initialized before main starts (only
> when it's first called).

There MIGHT be a way to fix this by snookering the linker into
not stripping code that is explicitly called. I've dealt with this on
a regular basis in the serialization library by forcing the export
of certain functions/instances so that the linker presumes that
the might be called from outside the executable. I get regular
complaints that "my executable is exporting entry points" but
I haven't found any other way to deal with it.

> Of course this optimization changes program behavior so it ought to be
> forbidden... but you know I'm paranoid ;-)

Well, just because you're paranoid doesn't mean that there isn't anyone
out to get you.

Robert Ramey

Boost list run by bdawes at, gregod at, cpdaniel at, john at