From: Marco Costalba Date: Sun, 27 Dec 2009 13:05:15 +0000 (+0100) Subject: Revert small pop_1st_bit() optimization X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=3f14f9a4782227107c4ced035da205b768839cbe;ds=sidebyside Revert small pop_1st_bit() optimization We cannot cast a pointer type to an unrelated pointer type. This is a violation of the strict aliasing rules. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 7d86884d..ca6c2003 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -348,19 +348,21 @@ union b_union { Square pop_1st_bit(Bitboard* bb) { - b_union* u; + b_union u; Square ret; - u = (b_union*)bb; + u.b = *bb; - if (u->dw.l) + if (u.dw.l) { - ret = Square(BitTable[((u->dw.l ^ (u->dw.l - 1)) * 0x783a9b23) >> 26]); - u->dw.l &= (u->dw.l - 1); + ret = Square(BitTable[((u.dw.l ^ (u.dw.l - 1)) * 0x783a9b23) >> 26]); + u.dw.l &= (u.dw.l - 1); + *bb = u.b; return ret; } - ret = Square(BitTable[((~(u->dw.h ^ (u->dw.h - 1))) * 0x783a9b23) >> 26]); - u->dw.h &= (u->dw.h - 1); + ret = Square(BitTable[((~(u.dw.h ^ (u.dw.h - 1))) * 0x783a9b23) >> 26]); + u.dw.h &= (u.dw.h - 1); + *bb = u.b; return ret; }