From 92901fb3bf07b178a0fb652a1e75cba0052063e3 Mon Sep 17 00:00:00 2001 From: Tomas Maly Date: Tue, 2 Jan 2024 05:03:11 +0100 Subject: [PATCH] workaround a crash in msvc --- sources/startingPositions.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sources/startingPositions.cpp b/sources/startingPositions.cpp index e5b5cee..59b7b8a 100644 --- a/sources/startingPositions.cpp +++ b/sources/startingPositions.cpp @@ -21,8 +21,15 @@ namespace unnatural return 0; Real score = Real::Infinity(); for (uint32 i = 0; i < n - 1; i++) + { for (uint32 j = i + 1; j < n; j++) - score = min(score, distance(tiles[positions[i]].position, tiles[positions[j]].position)); + { + const Real c = distance(tiles[positions[i]].position, tiles[positions[j]].position); + //score = min(score, c); // this causes a crash when compiled with visual studio 2022 msvc with optimizations + if (c < score) + score = c; + } + } return score; }