From: Marco Costalba Date: Sun, 16 Mar 2014 09:55:58 +0000 (+0100) Subject: Fix a crash under MSVC X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=fa3f6dcbead5366acbef23f241a141e3fa5c44f9 Fix a crash under MSVC Using memset on a std::vector is undefined behavior, so manually init all the data memebers of LimitsType. Bug intorduced in 41641e3b1eea0038ab6984 No functional change. --- diff --git a/src/search.h b/src/search.h index 3752dd70..a9f21fa2 100644 --- a/src/search.h +++ b/src/search.h @@ -20,7 +20,6 @@ #ifndef SEARCH_H_INCLUDED #define SEARCH_H_INCLUDED -#include #include #include #include @@ -78,7 +77,10 @@ struct RootMove { struct LimitsType { - LimitsType() { std::memset(this, 0, sizeof(LimitsType)); } + LimitsType() { // Using memset on a std::vector is undefined behavior + time[WHITE] = time[BLACK] = inc[WHITE] = inc[BLACK] = movestogo = + depth = nodes = movetime = mate = infinite = ponder = 0; + } bool use_time_management() const { return !(mate | movetime | depth | nodes | infinite); } std::vector searchmoves;