X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovegen.cpp;h=df2b9b87b1b2cd96adb42986b0e14e3be40c81dd;hp=ea58740f59ccadb3e9a71c5702831f7ef53a8b93;hb=605b3aedd5b2cc530db417fc8bb57cc45200cca1;hpb=9fc602bae74b8e09bd45ace3b42a8ce84d56b23c diff --git a/src/movegen.cpp b/src/movegen.cpp index ea58740f..df2b9b87 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -338,6 +338,10 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) { ||(square_rank(to) == RANK_1 && us != WHITE)) != bool(move_is_promotion(m))) return false; + // The promotion piece, if any, must be valid + if (move_promotion_piece(m) > QUEEN || move_promotion_piece(m) == PAWN) + return false; + // Proceed according to the square delta between the origin and // destination squares. switch (direction)