Skip to content

Gecode 7: bug fixes and Doxygen warnings - #292

Draft
zayenz wants to merge 7 commits into
feature/breaking-7-08-native-intervalfrom
feature/breaking-7-09-bug-fixes
Draft

zayenz wants to merge 7 commits into
feature/breaking-7-08-native-intervalfrom
feature/breaking-7-09-bug-fixes

Conversation

@zayenz

@zayenz zayenz commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

While putting Gecode 7 together, a number of real bugs and documentation mismatches turned up. I gathered them into this PR so reviewers can inspect actual behavior fixes separately from the large mechanical sweeps around them.

  • Test harness fixes: a reified float check used assignment where it meant comparison, so that branch never ran; set expression test names printed the relation enum as a raw number; and two MaybeType comments were swapped.
  • First MSVC C++23 CI fixes: bin packing switches to function pointers (later refined in Gecode 7: clang-tidy sweep #274 once the underlying MSVC name-lookup issue was isolated), Clang pragmas in core.hpp are guarded against MSVC warnings, the Qt consumer smokes match Comparator::compare's const& parameter, and generated-source freshness ignores Flex's #line numbers (which differ between Debian and Homebrew).
  • Realloc shrinking: shrinking through Space::realloc, Space::rrealloc, and Region::realloc computed the freed tail size as m - n instead of n - m, which underflowed. Space::realloc for pointer arrays also scaled the old size by sizeof(T) instead of sizeof(T*). In the same commit, val-commit returns ModEvent values properly and TFO guards its free.
  • Invalid argument checks: bin_packing with a dimension below 1 divided by d before checking it, and now throws Int::OutOfLimits first. The 2D element overloads (integer and set) accepted empty arrays and non-positive or overflowing matrix dimensions; they now throw TooFewArguments or ArgumentSizeMismatch.
  • Missing definitions and ignored assign selections: several exported declarations had no definitions (assign overloads taking TieBreak, FloatValArgs's initializer-list constructor, values_reflect(IntVar), three set value-iterator default constructors, and the pbs builder), and an unused DFAI(void) declaration is removed. In addition, plain assign with a variable selection used ViewSelNone and silently ignored the selection (affecting any TieBreak call that collapsed to one selection as well); all four variable types now expand and apply the selection.
  • FlatZinc branching fixes: IntBoolVarBranch silently passed its decay to VarBranch(Rnd) through the implicit Rnd(unsigned) constructor, losing the decay; Rnd(unsigned) is now explicit and default branchers honor -decay. Set and float value annotations took their relation-name output arguments by value, so names never reached callers. AuxVarBrancher copied only done when cloned, causing clones to fall back to default selections and leak the RNG of random selections; it now copies and disposes its selections properly.
  • Doxygen and sanitizer docs: 91 Doxygen warnings are cleared (almost all from parameter or type spellings that differed between declarations and definitions) with no behavioral change. The build documentation now also explains why OpenList overflows worker stacks in macOS Debug sanitizer builds: forced inlining at -O0 under ASan inflates some propagator frames to about 400 KiB against std::thread's 512 KiB default stack.

Stack

Merge in this order. #242 targets main, and each later PR builds on the one before it so its diff shows only its own commits. The first four PRs are standalone search and random-number changes; #284 through #274 are the Gecode 7 changes split out of what used to be a single branch.

  1. Rank solutions with Space::compare in best-solution search #242 Rank solutions with Space::compare
  2. Rename the meta-search hooks to hub and spoke #282 Rename the meta-search hooks to hub and spoke
  3. Give meta search hub and spoke contexts and report why search ended #283 Hub and spoke contexts and end reasons
  4. Add extensible random generators with reproducible stream splitting #241 Splittable random generators
  5. Gecode 7: CMake-only C++23 build baseline #284 Gecode 7: build baseline
  6. Gecode 7: format the sources with LLVM 22 #285 Gecode 7: reformat
  7. Gecode 7: normalized API names, LT constants and Clang checks #286 Gecode 7: API names, LT constants, checks
  8. Gecode 7: post nothing for empty arrays #287 Gecode 7: empty arrays
  9. Gecode 7: pass large parameters by const reference #288 Gecode 7: const& parameters
  10. Gecode 7: state and assert the heap size contract #289 Gecode 7: heap contract
  11. Gecode 7: trivially copyable handles and defaulted special members #290 Gecode 7: modern classes
  12. Gecode 7: native float interval instead of Boost #291 Gecode 7: native float interval
  13. Gecode 7: bug fixes and Doxygen warnings #292 Gecode 7: bug fixes and Doxygen ← this PR
  14. Gecode 7: scoped enums and descriptive constant names #293 Gecode 7: scoped enums
  15. Gecode 7: clang-tidy sweep #274 Gecode 7: clang-tidy sweep

A reified float check assigned where it compared, so its branch never ran. Set expression test names printed the relation as a number, and the MaybeType comments were swapped.

Zdev-Change-Id: Z6305fbd9964e39543d52b4bd2830daf68ee6af4c47853f2d445eb63ef56cbd0a
MSVC rejects a call through a function-typed template parameter under C++23, so bin packing now takes function pointers. The clang pragmas in core.hpp are guarded, since MSVC warns about them. The Qt consumer smokes use the const reference that Comparator::compare takes now, and the freshness check ignores the numbers on flex's #line directives for its own output, which differ between Debian and Homebrew.

Zdev-Change-Id: Z69203daf7cf88277567379d57e3996fd5d0da801830c25c15f15cebfcf3e404d
Shrinking through Space::realloc, Space::rrealloc, and Region::realloc computed the removed tail as m - n, which underflowed. Space::realloc for pointers used the size of the pointed-to type on the old size. val-commit now returns ModEvent values and TFO guards its free.

Zdev-Change-Id: Z5872dea6437a9011a18767ce18e6729556e984cbc7ebf62b6f405c49bf145adf
bin_packing with a dimension below one divided by d before any check. It now throws Int::OutOfLimits first.

The 2D element overloads accepted an empty array and non-positive or overflowing matrix shapes. They now throw TooFewArguments or ArgumentSizeMismatch, in both the integer and set modules.

Zdev-Change-Id: Z565281c0945c5a63b7843b9908ecbac41046a69a829acb84096037fcd419b839
The assign overloads with TieBreak and the FloatValArgs initializer-list constructor were declared without matching definitions. An audit of exported declarations found values_reflect(IntVar), three set value iterator default constructors, and the pbs builder declaration in the same state, and an undefined DFAI(void) that is removed.

Plain assign with a variable selection used ViewSelNone and ignored the selection, so a TieBreak call that reduced to one selection ignored it too. All four variable types now expand and use the selection, taking it by value as branch does.

Zdev-Change-Id: Z80dbbc163338547c5a4c41c647d65d959c4774e52ffbb17c4957471393701bbb
IntBoolVarBranch passed its decay to VarBranch(Rnd) through the implicit Rnd(unsigned), so decay was lost. It now keeps its decay, Rnd(unsigned) is explicit, and the default branchers follow the -decay option.

The set and float value annotations took their relation names by value, so the names never reached the caller.

AuxVarBrancher copied only done when cloned, so a clone fell back to default selections. It now copies its selections and disposes them, which also stops leaking the random number generator of a random selection.

Zdev-Change-Id: Zcb5ff72b63e0edbd4e44410dbadd56712c19b264e6ea05aac11bb71d1d84c273
Doxygen reported 91 warnings, nearly all from definitions spelled differently from their declarations. The spellings now match, with no change in behaviour.

OpenList overflowed a worker stack in a macOS Debug sanitizer build. That is not a Gecode bug: forced inlining at -O0 with ASan gives some propagators a frame of about 400 KiB, and std::thread stacks are 512 KiB. The build reference now says so.

The three set value iterator default constructors added earlier are defaulted, which the lint step requires.

Zdev-Change-Id: Ze86a35bdb31538eca9f2b216a4cbe8fd644de23511da761ea9a33be912d6fbfe

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant