Domanda

When I try to add a pair to a vector I get this error:

table: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Aborted

Here is the method:

std::vector<std::pair <int, int> > AI::genPosNormal(int p, int dice)
{
  std::vector<std::pair <int, int> > pos;
  std::pair<int, int> step;

  for(int i = p; i < 25-dice; i++){
    if(board[BLACK][i] > 0 && board[WHITE][i+dice] < 2){
      step.first = i;
      step.second = dice;
      pos.push_back(step);
    }
  }
  return pos;
}
È stato utile?

Soluzione

A little to late. But I found using .reserve() in std::vector of std::pair resolves the issue. I still have to figure out why the error is caused but seems like there in an stl_uninitialized.h which raises an error flag.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top