Hi!
I have come across some weird behavior the other day which results in unexplained segmentation faults. Let's say I have a program which reads:
Code:
#include <iostream>
#include <vector>
using namespace std;
class SomeClass
{
};
void someFunc()
{
vector<SomeClass*> HugeArray[1000][1000];
HugeArray[0][0].clear();
}
int main()
{
someFunc();
return 0;
}
It compiles fine, but then sigsegvs on me upon entering someFunc (when control has not even yet reached the clear()-call). But if I make the function global, it runs perfectly fine:
Code:
#include <iostream>
#include <vector>
using namespace std;
class SomeClass
{
};
vector<SomeClass*> HugeArray[1000][1000];
void someFunc()
{
HugeArray[0][0].clear();
}
int main()
{
someFunc();
return 0;
}
It also runs fine without making HugeArray global, but then I have to reduce its size to f.ex. 100x100.
Is this a compiler-related problem? I have tried this on GCC 4.x
Thanks in advance