From: Marco Costalba Date: Sat, 10 Oct 2009 08:48:02 +0000 (+0100) Subject: Fix pieceList initialization in Position::clear() X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=a806d7c3d65bdea85125aa3611537974c6e0c030 Fix pieceList initialization in Position::clear() We want piece list to be terminated with SQ_NONE. This happens with all the pieces but the pawns that being 8 make the inner loop exit just before writing the SQ_NONE value at the tail of the list. This bug was hidden because currently we don't use piece list to scan pawns, but this will change in the future and in any case an initialization should be done correctly for the whole array to avoid subtle bugs in the future. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/position.cpp b/src/position.cpp index 4e9a6dc7..388f91f3 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1488,8 +1488,8 @@ void Position::clear() { for (int i = 0; i < 64; i++) board[i] = EMPTY; - for (int i = 0; i < 7; i++) - for (int j = 0; j < 8; j++) + for (int i = 0; i < 8; i++) + for (int j = 0; j < 16; j++) pieceList[0][i][j] = pieceList[1][i][j] = SQ_NONE; sideToMove = WHITE;