1

ベクトルにペアを追加しようとすると、次のエラーが発生します。

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;
}
4

1 に答える 1

1

少し遅め。しかし、 std::pair の std::vector で .reserve() を使用すると、問題が解決することがわかりました。エラーが発生した理由を突き止める必要がありますが、エラーフラグを立てる stl_uninitialized.h にあるようです。

于 2014-06-26T19:36:52.177 に答える