]> git.sesse.net Git - stockfish/commit
Check for overflow in Score * int multiplication (#969)
authorStéphane Nicolet <cassio@free.fr>
Wed, 11 Jan 2017 17:11:17 +0000 (18:11 +0100)
committerMarco Costalba <mcostalba@users.noreply.github.com>
Wed, 11 Jan 2017 17:11:17 +0000 (18:11 +0100)
commitd2971f3fca929d9085ed17b71aa4ec8e96499d99
treedd1a701a5a4e778e47916f8f31d0fd3e2949db18
parentd40351243b7256a867f43741c3a53ceb781fbca1
Check for overflow in Score * int multiplication (#969)

Add asserts to check for overflow in Score * int multiplication.

There is no overflow in current master, but it would be easy to
create one as the scale of the current eval does not leave many
spare bits. For instance, adding the following unused variables
in master at the end of evaluate() (line 882 of evaluate.cpp)
overflows:

Score s1 = score * 4;  // no overflow
Score s2 = score * 5;  // overflow

Assertion failed: (eg_value(result) == (i * eg_value(s))),
function operator*, file ./types.h, line 336.

Same md5 checksum as current master for non debug compiles.

No functional change.
src/types.h