]> git.sesse.net Git - stockfish/commitdiff
Fix a crash under MSVC
authorMarco Costalba <mcostalba@gmail.com>
Sun, 16 Mar 2014 09:55:58 +0000 (10:55 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 16 Mar 2014 09:55:58 +0000 (10:55 +0100)
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.

src/search.h

index 3752dd70b0fd492eddaf90ba8d1455249068a43e..a9f21fa2368febfdfcc37eaf71f9922ea85f0607 100644 (file)
@@ -20,7 +20,6 @@
 #ifndef SEARCH_H_INCLUDED
 #define SEARCH_H_INCLUDED
 
-#include <cstring>
 #include <memory>
 #include <stack>
 #include <vector>
@@ -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<Move> searchmoves;