From: Roy S. <roy...@ic...> - 2013-04-03 16:53:51
|
On Wed, 3 Apr 2013, Derek Gaston wrote: > I can't see how the container is not created yet... that would be a > segfault when you try to push_back on it.... No, that would be undefined behavior when you try to push_back on it. "undefined behavior" only means a segfault when it ends up hitting memory outside the process' current address space. > not too mention that the code that actually does the pushing back is > in Singleton.C which is where the container is... so it would have > had to have been created by the time you call that function... Doesn't matter. What C++ is doing under the hood is: Construct A Construct B except in random order (which is why stuff worked fine for Ben), not alphabetical order. And if A's constructor calls a function dealing with B, there's neither compile-time nor run-time analysis done to detect that and say "whoops, let's construct B before A". --- Roy |