I am certain I have done something wrong to make this happen. I am using a library that declares a map statically in a way that seems to make sense.
In the header, in a class called Codec:
typedef map< String, Codec* >::type CodecList;
static CodecList msMapCodecs;
In the cpp file:
map< String, Codec * >::type Codec::msMapCodecs;
When I put a breakpoint on the line in the cpp file I have seen that it calls this in a stack frame called "__static_initialization_and_destruction_0" and if I step into it I can see it call the constructor for this map before main is reached. Just after main starts I insert some entries via function calls of the library API, then I notice the constructor is called a second time in a similar way to first.
What could cause this, or what and I misunderstanding that could confuse me enough to think this is happening? I have searched and I don't see an explicit calls to the constructor. I could not duplicate this in a minimal test case. I know that providing an exact answer is not possible, but anything that will point me a good direction would be appreciated.
If it matters I am using gcc 4.6.3 on Ubuntu 12.04. x64