Vector inicialization problem

Hi everyone!
I'm having a strange issue working with vectors

I have a class that has some vectors, as seen below:

1
2
3
4
5
6
7
8
class leach_c{
    public:
        dados d;
        int numClusterHead;
        vector<double> distanceToSink;
        vector<int> ch_index; //variavel que guarda quem é o ch de cada no
        vector<int> ch_list; //variável que guarda quem são os cluesters head no round atual
        vector<int> dead_nodes_list; //variavel de estatistica que guarda a quantidade de nós mortos a cada round 


on the class leach_c constructor, I initialize these vectors:

1
2
3
4
5
6
7
8
9
10
11
12
13
leach_c::leach_c(){
    d.setup();
    numClusterHead = ceil(numnodes * PorcentagemClusterHead);
    for(int i = 0; i < numnodes; i++){
        distanceToSink.push_back(sqrt(pow(d.coord[i][0] - baseStationX, 2) + pow(d.coord[i][1] - baseStationY,2)));
    }

    for(int i = 0; i < numClusterHead; i++)
        ch_list.push_back(-1);

    for(int i = 0; i < numnodes; i++)
        ch_index.push_back(-1);
}


it works fine, but the problem is when I set the numnodes variable with a low value. If I put 15 or above it works ok. But with values such as 10, 11, 12... every push_back operation on these vectors are giving me a segmentation fault and it goes to the vector class and highlight this part on the new_alocator.h file:
1
2
3
4
5
// _GLIBCXX_RESOLVE_LIB_DEFECTS
      // 402. wrong new expression in [some_] allocator::construct
      void 
      construct(pointer __p, const _Tp& __val) 
      { ::new((void *)__p) _Tp(__val); }


anyone has a clue of why this is happening? =(
Topic archived. No new replies allowed.