Fix one error and all warnings on MSVC 2026

The error is "C1001: Internal compiler error." in uci.cpp on line 370 of
master.  For some reason the compiler can't handle the
std::size(hashfullAges) inside the lambda.  Older MSVC versions had no
problem.

Most of the warnings are due to implicit type conversions "conversion
from type A to type B, possible loss of data"
many of which have been present for a while.

closes https://github.com/official-stockfish/Stockfish/pull/6464

No functional change
This commit is contained in:
mstembera
2025-12-21 15:43:32 +01:00
committed by Disservin
parent 8449e5eb9d
commit e1c919fd7e
7 changed files with 23 additions and 19 deletions
+2 -2
View File
@@ -454,7 +454,7 @@ BenchmarkSetup setup_benchmark(std::istream& is) {
int desiredTimeS; int desiredTimeS;
if (!(is >> setup.threads)) if (!(is >> setup.threads))
setup.threads = get_hardware_concurrency(); setup.threads = int(get_hardware_concurrency());
else else
setup.originalInvocation += std::to_string(setup.threads); setup.originalInvocation += std::to_string(setup.threads);
@@ -486,7 +486,7 @@ BenchmarkSetup setup_benchmark(std::istream& is) {
int ply = 1; int ply = 1;
for (int i = 0; i < static_cast<int>(game.size()); ++i) for (int i = 0; i < static_cast<int>(game.size()); ++i)
{ {
const float correctedTime = getCorrectedTime(ply); const float correctedTime = float(getCorrectedTime(ply));
totalTime += correctedTime; totalTime += correctedTime;
ply += 1; ply += 1;
} }
+5 -3
View File
@@ -48,13 +48,15 @@ inline int pawn_history_index(const Position& pos) {
return pos.pawn_key() & (PAWN_HISTORY_SIZE - 1); return pos.pawn_key() & (PAWN_HISTORY_SIZE - 1);
} }
inline uint16_t pawn_correction_history_index(const Position& pos) { return pos.pawn_key(); } inline uint16_t pawn_correction_history_index(const Position& pos) {
return uint16_t(pos.pawn_key());
}
inline uint16_t minor_piece_index(const Position& pos) { return pos.minor_piece_key(); } inline uint16_t minor_piece_index(const Position& pos) { return uint16_t(pos.minor_piece_key()); }
template<Color c> template<Color c>
inline uint16_t non_pawn_index(const Position& pos) { inline uint16_t non_pawn_index(const Position& pos) {
return pos.non_pawn_key(c); return uint16_t(pos.non_pawn_key(c));
} }
// StatsEntry is the container of various numerical statistics. We use a class // StatsEntry is the container of various numerical statistics. We use a class
+4 -3
View File
@@ -171,9 +171,10 @@ class FeatureTransformer {
read_leb_128<WeightType>(stream, *combinedWeights); read_leb_128<WeightType>(stream, *combinedWeights);
std::copy(combinedWeights->begin(), std::transform(combinedWeights->begin(),
combinedWeights->begin() + ThreatInputDimensions * HalfDimensions, combinedWeights->begin() + ThreatInputDimensions * HalfDimensions,
std::begin(threatWeights)); std::begin(threatWeights),
[](WeightType w) { return static_cast<ThreatWeightType>(w); });
std::copy(combinedWeights->begin() + ThreatInputDimensions * HalfDimensions, std::copy(combinedWeights->begin() + ThreatInputDimensions * HalfDimensions,
combinedWeights->begin() combinedWeights->begin()
+2 -2
View File
@@ -584,7 +584,7 @@ int decompress_pairs(PairsData* d, uint64_t idx) {
// idx = k * d->span + idx % d->span (2) // idx = k * d->span + idx % d->span (2)
// //
// So from (1) and (2) we can compute idx - I(K): // So from (1) and (2) we can compute idx - I(K):
int diff = idx % d->span - d->span / 2; int diff = int(idx % d->span - d->span / 2);
// Sum the above to offset to find the offset corresponding to our idx // Sum the above to offset to find the offset corresponding to our idx
offset += diff; offset += diff;
@@ -1092,7 +1092,7 @@ uint8_t* set_sizes(PairsData* d, uint8_t* data) {
// See https://web.archive.org/web/20201106232444/http://www.larsson.dogma.net/dcc99.pdf // See https://web.archive.org/web/20201106232444/http://www.larsson.dogma.net/dcc99.pdf
std::vector<bool> visited(d->symlen.size()); std::vector<bool> visited(d->symlen.size());
for (std::size_t sym = 0; sym < d->symlen.size(); ++sym) for (Sym sym = 0; sym < d->symlen.size(); ++sym)
if (!visited[sym]) if (!visited[sym])
d->symlen[sym] = set_symlen(d, sym, visited); d->symlen[sym] = set_symlen(d, sym, visited);
+2 -2
View File
@@ -283,8 +283,8 @@ void ThreadPool::start_thinking(const OptionsMap& options,
{ {
th->run_custom_job([&]() { th->run_custom_job([&]() {
th->worker->limits = limits; th->worker->limits = limits;
th->worker->nodes = th->worker->tbHits = th->worker->nmpMinPly = th->worker->nodes = th->worker->tbHits = th->worker->bestMoveChanges = 0;
th->worker->bestMoveChanges = 0; th->worker->nmpMinPly = 0;
th->worker->rootDepth = th->worker->completedDepth = 0; th->worker->rootDepth = th->worker->completedDepth = 0;
th->worker->rootMoves = rootMoves; th->worker->rootMoves = rootMoves;
th->worker->rootPos.set(pos.fen(), pos.is_chess960(), &th->worker->rootState); th->worker->rootPos.set(pos.fen(), pos.is_chess960(), &th->worker->rootState);
+1 -1
View File
@@ -91,7 +91,7 @@ void TimeManagement::init(Search::LimitsType& limits,
// If less than one second, gradually reduce mtg // If less than one second, gradually reduce mtg
if (scaledTime < 1000) if (scaledTime < 1000)
centiMTG = scaledTime * 5.051; centiMTG = int(scaledTime * 5.051);
// Make sure timeLeft is > 0 since we may use it as a divisor // Make sure timeLeft is > 0 since we may use it as a divisor
TimePoint timeLeft = TimePoint timeLeft =
+7 -6
View File
@@ -313,8 +313,8 @@ void UCIEngine::benchmark(std::istream& args) {
Benchmark::BenchmarkSetup setup = Benchmark::setup_benchmark(args); Benchmark::BenchmarkSetup setup = Benchmark::setup_benchmark(args);
const int numGoCommands = count_if(setup.commands.begin(), setup.commands.end(), const auto numGoCommands = count_if(setup.commands.begin(), setup.commands.end(),
[](const std::string& s) { return s.find("go ") == 0; }); [](const std::string& s) { return s.find("go ") == 0; });
TimePoint totalTime = 0; TimePoint totalTime = 0;
@@ -361,13 +361,14 @@ void UCIEngine::benchmark(std::istream& args) {
int numHashfullReadings = 0; int numHashfullReadings = 0;
constexpr int hashfullAges[] = {0, 999}; // Only normal hashfull and touched hash. constexpr int hashfullAges[] = {0, 999}; // Only normal hashfull and touched hash.
int totalHashfull[std::size(hashfullAges)] = {0}; constexpr int hashfullAgeCount = std::size(hashfullAges);
int maxHashfull[std::size(hashfullAges)] = {0}; int totalHashfull[hashfullAgeCount] = {0};
int maxHashfull[hashfullAgeCount] = {0};
auto updateHashfullReadings = [&]() { auto updateHashfullReadings = [&]() {
numHashfullReadings += 1; numHashfullReadings += 1;
for (int i = 0; i < static_cast<int>(std::size(hashfullAges)); ++i) for (int i = 0; i < hashfullAgeCount; ++i)
{ {
const int hashfull = engine.get_hashfull(hashfullAges[i]); const int hashfull = engine.get_hashfull(hashfullAges[i]);
maxHashfull[i] = std::max(maxHashfull[i], hashfull); maxHashfull[i] = std::max(maxHashfull[i], hashfull);
@@ -554,7 +555,7 @@ int UCIEngine::to_cp(Value v, const Position& pos) {
auto [a, b] = win_rate_params(pos); auto [a, b] = win_rate_params(pos);
return std::round(100 * int(v) / a); return int(std::round(100 * int(v) / a));
} }
std::string UCIEngine::wdl(Value v, const Position& pos) { std::string UCIEngine::wdl(Value v, const Position& pos) {