1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 01:03:09 +00:00
BadFish/src
Marco Costalba 4eee603433 Fix a subtle bug in UCI options printing
We want all the UCI options are printed in the order in which are
assigned, so we use an index that, depending on Options.size(),
increases after each option is added to the map. The problem is
that, for instance, in the first assignment:

o["Write Debug Log"] = Option(false, on_logger);

Options.size() can value 0 or 1 according if the l-value (that
increments the size) has been evaluated after or before the
r-value (that uses the size value).

The culprit is that assignment operator in C++ is not a
sequence point:

http://en.wikipedia.org/wiki/Sequence_point

(Note: to be nitpick here we actually use std::map::operator=()
 that being a function can evaluate its arguments in any order)

So there is no guarantee on what term is evaluated first and
behavior is undefined by standard in this case. The net result
is that in case r-value is evaluated after l-value the last
idx is not size() - 1, but size() and in the printing loop
we miss the last option!

Bug was there since ages but only recently has been exposed by
the removal of UCI_Analyze option so that the last one becomes
UCI_Chess960 and when it is missing engine cannot play anymore
Chess960.

The fix is trivial (although a bit hacky): just increase the
last loop index.

Reported by Eric Mullins that found it on an ARM and MIPS
platforms with gcc 4.7

No functional change.
2014-03-22 11:30:06 +01:00
..
benchmark.cpp Print dbg counters after bench 2014-03-11 22:19:14 +01:00
bitbase.cpp Additional renaming from DON 2014-02-14 09:42:50 +01:00
bitboard.cpp Simplify Bitboards::pretty 2014-03-01 13:10:05 +01:00
bitboard.h Assorted grammar fixes 2014-01-07 14:30:41 +09:00
bitcount.h Update copyright year 2014-01-02 01:49:18 +01:00
book.cpp Assorted grammar fixes 2014-01-07 14:30:41 +09:00
book.h Update copyright year 2014-01-02 01:49:18 +01:00
endgame.cpp Use legal positions for endgame initialization 2014-03-14 09:57:34 +01:00
endgame.h Simplify pawnless endgame evaluation 2014-01-18 17:22:54 +01:00
evaluate.cpp Some minor cleanup stuff 2014-03-03 08:57:20 +01:00
evaluate.h Update copyright year 2014-01-02 01:49:18 +01:00
main.cpp Assorted tweaks from DON 2014-02-09 17:31:45 +01:00
Makefile Re-add link time optimization on OS X 2014-03-14 08:49:08 +01:00
material.cpp Fix a typo 2014-03-18 18:36:39 +01:00
material.h Update copyright year 2014-01-02 01:49:18 +01:00
misc.cpp Fix dbg_mean_of() for negative numbers 2014-03-05 08:55:12 +01:00
misc.h Additional renaming from DON 2014-02-14 09:42:50 +01:00
movegen.cpp Simplify generate<EVASIONS> 2014-03-09 12:16:27 +01:00
movegen.h Update copyright year 2014-01-02 01:49:18 +01:00
movepick.cpp Update SEE to return a Value 2014-02-16 13:06:31 +01:00
movepick.h Update SEE to return a Value 2014-02-16 13:06:31 +01:00
notation.cpp Rename xxx_to_char() -> to_char() 2014-03-01 22:07:41 +01:00
notation.h Fix a compiler warning 2014-02-12 21:52:21 +01:00
pawns.cpp Rename castling flag to castling right 2014-03-08 15:08:55 +01:00
pawns.h Rename castling flag to castling right 2014-03-08 15:08:55 +01:00
platform.h Update copyright year 2014-01-02 01:49:18 +01:00
position.cpp Merge default tests in pos_is_ok 2014-03-15 15:34:31 +01:00
position.h Merge default tests in pos_is_ok 2014-03-15 15:34:31 +01:00
psqtab.h H-file penalty and center bonus 2014-02-03 21:23:49 +01:00
rkiss.h Move magic random to RKISS 2014-02-12 14:47:36 +01:00
search.cpp Increase max threads to 128 2014-03-18 12:07:26 +01:00
search.h Fix a crash under MSVC 2014-03-16 10:55:58 +01:00
thread.cpp Increase max threads to 128 2014-03-18 12:07:26 +01:00
thread.h Increase max threads to 128 2014-03-18 12:07:26 +01:00
timeman.cpp Simplify time management 2014-02-12 20:01:11 +01:00
timeman.h Distribute part of first move time to other moves 2014-02-20 08:39:00 +01:00
tt.cpp Assorted tweaks from DON 2014-02-09 17:31:45 +01:00
tt.h Some minor cleanup stuff 2014-03-03 08:57:20 +01:00
types.h Rename castling flag to castling right 2014-03-08 15:08:55 +01:00
uci.cpp Assorted tweaks from DON 2014-02-09 17:31:45 +01:00
ucioption.cpp Fix a subtle bug in UCI options printing 2014-03-22 11:30:06 +01:00
ucioption.h Assorted tweaks from DON 2014-02-09 17:31:45 +01:00