]> git.sesse.net Git - stockfish/commitdiff
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)
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>

No differences found