mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Workaround value-initialization in MSVC
The syntax splitPoints() should force the compiler to value-initialize the array and because there is no user defined c'tor it falls back on zero-initialization. Unfortunatly this is broken in MSVC compilers, because value initialization for non-POD types is not supported, so left splitPoints un-initialized and add in split() initialization of slavesPositions, that is the only member not already set at split time. This fixes an assert under MSVC when running with more than one thread. Spotted and reported by Jundery. No functional change.
This commit is contained in:
parent
c67fb8ef04
commit
50a7200b18
1 changed files with 4 additions and 1 deletions
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <algorithm> // For std::count
|
#include <algorithm> // For std::count
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstring> // For memset
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "movegen.h"
|
#include "movegen.h"
|
||||||
|
@ -43,7 +44,7 @@ namespace { extern "C" {
|
||||||
// Thread c'tor starts a newly-created thread of execution that will call
|
// Thread c'tor starts a newly-created thread of execution that will call
|
||||||
// the the virtual function idle_loop(), going immediately to sleep.
|
// the the virtual function idle_loop(), going immediately to sleep.
|
||||||
|
|
||||||
Thread::Thread() : splitPoints() {
|
Thread::Thread() /* : splitPoints() */ { // Value-initialization bug in MSVC
|
||||||
|
|
||||||
searching = exit = false;
|
searching = exit = false;
|
||||||
maxPly = splitPointsSize = 0;
|
maxPly = splitPointsSize = 0;
|
||||||
|
@ -280,6 +281,8 @@ void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bes
|
||||||
sp.cutoff = false;
|
sp.cutoff = false;
|
||||||
sp.ss = ss;
|
sp.ss = ss;
|
||||||
|
|
||||||
|
memset(sp.slavesPositions, 0, sizeof(sp.slavesPositions));
|
||||||
|
|
||||||
// Try to allocate available threads and ask them to start searching setting
|
// Try to allocate available threads and ask them to start searching setting
|
||||||
// 'searching' flag. This must be done under lock protection to avoid concurrent
|
// 'searching' flag. This must be done under lock protection to avoid concurrent
|
||||||
// allocation of the same slave by another master.
|
// allocation of the same slave by another master.
|
||||||
|
|
Loading…
Add table
Reference in a new issue