Please help,
The problem: core dumps in following code:
I have an abstract class SomeOtherClass, and have derived from it SomeOtherClassImpl.
Here is the code which causes the trouble:
class MyClass
{
public:
void someFunction()
{
myVector().push_back(someOtherClassDefault());
}
private:
static std::vector<SomeOtherClass const *> & myVector()
{
static std::vector<SomeOtherClass const *> theVector;
return theVector;
}
static SomeOtherClass const * someOtherClassDefault()
{
static SomeOtherClassImpl theDefault;
return &theDefault;
}
};
I have some static variables of MyClass type in other translation units.
The problem is weird as segmentation fault occures when program exits. Of course theDefault can be deallocated before theVector, but what's the difference? Both deallocated when main is already done.
You help will be much appreciated.