]> git.sesse.net Git - stockfish/commit
Fix reading of book file
authorMarco Costalba <mcostalba@gmail.com>
Sat, 7 May 2011 08:03:59 +0000 (09:03 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 7 May 2011 08:51:33 +0000 (09:51 +0100)
commit2535dc13403acba764696587b920dee9493ddddd
treec32c0396512db5df6352b1cbf676a4d368f6d4b5
parent339bf9b7e1bf812b1756bb79c1ba7d7b5ea4dd9a
Fix reading of book file

Bug is subtle because appears only under MSVC 32 bits in
optimized version, hence was missed before.

Bug is due to the fact that evaluation order of terms of a
sum is undefined by the standard, so in get_int() we have:

return 256 * get_int<n-1>() + bookFile.get();

And if get() is evaluated before get_int() we have a corrupted
key.

The patch rewrites the code in a more natural and predictable way.

No functional change.

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