Repository navigation
Conversation
Release builds made with Visual Studio 2026 (MSVC 19.52.37029) lose solutions on basic integer constraints. On a 26-case reproducer from MiniZinc's FindMUS team, 21 cases return too few solutions, including length-1 comparisons such as x < y (0 of 3) and x == y (1 of 3) and a satisfiable 3x3 model that reports UNSATISFIABLE. gecode-test fails immediately on Int::Distinct::Bnd::Dense. Rebuilding Gecode 6.6.1 on GitHub Actions with MSVC 19.52 reproduces the same 21 failures on both windows-11-arm (ARM64) and windows-2025 (x64) when GECODE_ASSUME expands to __assume. Defining GECODE_ASSUME empty makes all 26 cases and the Int::Rel and Int::Distinct tests pass on both architectures. The asserted properties hold and are checked in Debug builds in per-PR CI, so this is an MSVC 19.52 optimizer bug triggered by __assume. It was only noticed on ARM64 because Gecode CI and MiniZinc's x64 package still build with Visual Studio 2022. Define GECODE_ASSUME(p) as assert((p)) on all compilers in gecode/support/macros.hpp; non-MSVC compilers never used an optimizer hint there. Pass /bigobj to MSVC C++ compiles in CMakeLists.txt so gecode/int/extensional-tuple-set.cpp builds on ARM64 without hitting C1128 (too many sections). Add a build-windows-arm64 job to .github/workflows/release-matrix.yml on windows-11-arm using the runner's default Visual Studio in a static Release build that runs the check target. That job would have caught both problems.
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix · Severity of issue fixed: Medium Merge Risk:
|
Release builds of Gecode compiled with Visual Studio 2026 (MSVC 19.52) lose solutions on basic integer constraints on both ARM64 and x64. The MiniZinc FindMUS team reported the failure on Gecode 6.6.1 built for Windows ARM64 (
minizinc-vendor), where a satisfiable 3x3 FlatZinc model (all_differenton one column and twolex_lessconstraints) returnedUNSATISFIABLE.The root cause is an MSVC 19.52 optimizer bug triggered by
__assumeinGECODE_ASSUME. Removing__assumefixes the miscompilation, passing/bigobjfixes the MSVC ARM64 build, and a new Windows ARM64 release-matrix job tests both.Cause
The FindMUS reproducer uses the C++ API to count solutions against brute force for
rel(home, x, irt, y)onIntVarArgsacross all relations and lengths 1..4 over domains 1..3, plusdistinctand the 3x3 model. On Linux x64 all 26 cases match brute force. On Windows ARM64 Release, 21 of 26 cases fail: every case except!=anddistinctloses solutions. Length-1 comparisons fail too (x < yyields 0 of 3 solutions,x == yyields 1 of 3). Because length-1 lex posts the binaryLe/Lqpropagators and lex==postsEqDom, the bug was not in the lex propagator.To isolate it, Gecode 6.6.1 was built in Release with MSVC 19.52.37029 (Visual Studio 2026) on GitHub Actions (
zayenz/gecode, branchdebug/win-arm-lex) on bothwindows-11-arm(ARM64) andwindows-2025(x64, which also ships MSVC 19.52), with and without__assume:GECODE_ASSUME(p)defined as__assume((p))(the default under_MSC_VER && NDEBUG), both ARM64 and x64 fail the same 21 of 26 reproducer cases, andgecode-testfails immediately onInt::Distinct::Bnd::Dense.GECODE_ASSUMEdefined empty, all 26 cases pass on both architectures, and theInt::RelandInt::Distincttest suites pass.The trigger is MSVC 19.52, not ARM64. It looked ARM64-specific only because Gecode's CI and MiniZinc's x64 Windows package still build on
windows-2022(Visual Studio 2022), whereaswindows-11-armships Visual Studio 2026.The asserted conditions hold: on all other compilers
GECODE_ASSUMEis a normalassert, and per-PR CI checks them in Debug builds (check-extended).GECODE_ASSUMEis used inIntVarImpbound updates (lq/gq/eq, asserting the result isFAILED,VAL, orBND), float variable updates, kernel core,thread.cpp, and a few graph, extensional, and tuple-set paths. A small standalone copy of theIntVarImppattern did not reproduce the miscompile, so there is no minimal bug report for Microsoft yet.Changes
gecode/support/macros.hpp: defineGECODE_ASSUME(p)asassert((p))on all compilers instead of expanding to__assume((p))in MSVC Release builds. Other compilers never had an optimizer hint there.CMakeLists.txt: pass/bigobjto MSVC C++ compiles. Without it,gecode/int/extensional-tuple-set.cppfails on ARM64 with C1128 (too many sections), whichminizinc-vendorworked around viaCXXFLAGS. (The removed Autoconf build always passed-bigobj;mainis CMake-only.).github/workflows/release-matrix.yml: addbuild-windows-arm64onwindows-11-armusing the runner's default (newest) Visual Studio, static Release configuration, running thechecktarget. That job would have caught both problems.changelog.in: add two entries in the unreleased 7.0.0 section.Testing
The release-matrix workflow runs on
workflow_dispatch, pushes torelease/**, and pull requests that touch.github/workflows/release-matrix.yml. Because the workflow file changes here,build-windows-arm64runs automatically on the pull request: it builds a static Release configuration onwindows-11-armwith Visual Studio 2026 and runscheck.Follow-up
This fix should be backported for a 6.6.2 release together with the FlatZinc blackbox improvements and PR #302. On 6.6.x, the bundled Boost.Interval header
hw_rounding.hppalso needs to recognize_MSVC_LANGso ARM64 MSVC builds do not require/Zc:__cplusplus;mainno longer has that code.Summary by CodeRabbit