Silence idiotic warning on two's complement of an unsigned
authorMarco Costalba <mcostalba@gmail.com>
Mon, 30 Mar 2009 10:07:45 +0000 (12:07 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 31 Mar 2009 19:50:10 +0000 (20:50 +0100)
MSVC gives:

warning C4146: unary minus operator applied to unsigned type,
               result still unsigned

When finds -b where b is an unsigned integer. So rewrite the two's
complement in a way to avoid the warning. Theoretically the new
version is slower, but in practice changes nothing.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/position.cpp

index 1081e1da9e723e1e4834fa23ce0f8437f8b4c09c..cdbd9f0d1963ff13486c986c401e340e1c960d03 100644 (file)
@@ -1618,7 +1618,7 @@ int Position::see(Square from, Square to) const {
       // Remove the attacker we just found from the 'attackers' bitboard,
       // and scan for new X-ray attacks behind the attacker.
       b = attackers & pieces_of_color_and_type(c, pt);
-      occ ^= (b & -b);
+      occ ^= (b & (~b + 1));
       attackers |=  (rook_attacks_bb(to, occ) & rooks_and_queens())
                   | (bishop_attacks_bb(to, occ) & bishops_and_queens());