当我尝试将一对添加到矢量时,我收到此错误:
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
以下是方法:
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;
}
答案 0 :(得分:1)
有点迟到。但我发现在std :: vector的std :: vector中使用.reserve()解决了这个问题。我仍然需要找出导致错误的原因,但似乎在stl_uninitialized.h中引发了错误标志。