Repository navigation
Conversation
An Action or CHB over an empty array keeps its shared storage, so it stays initialized with size zero, copyable, and an empty Action still accepts a decay change. It no longer requests or frees a zero-size element buffer and no longer posts a recorder propagator. Zdev-Change-Id: Zd4e6b819bd4f6bcd64b83d6fcd1a94d1bdf26ec1dc2e580c53e90ed98a16a1c9
TupleSet, Archive, Space::rrealloc, the FlatZinc set and regular builtins, the example dictionary, DFA and TupleSet construction from a DFA, and IntSet initializer lists no longer request zero bytes from the heap or a region and no longer pass null pointers to memcpy. Buffers that can now be null are freed only when non-null. An empty initializer list gives the empty IntSet, and a FlatZinc regular constraint with a reversed final-state range treats it as empty. Zdev-Change-Id: Z739fba34334ff1732238cd5ef32e1903b009ce0fe1dcc1ec967ee3213b53009f
Heap requests now document that allocation sizes are positive, that realloc may grow from zero elements, and that copy needs non-null pointers even for zero elements. Debug builds assert a positive size in Heap::ralloc and rrealloc, and rrealloc no longer accepts zero. Two lint findings are fixed: an intentional copy in the branch tests gets a NOLINT, and an assert in TupleSet finalization documents a count that clang-analyzer cannot follow. Zdev-Change-Id: Z56a1f083f220acb099fd0bc9a9ac161b74b110451fa021068f6b7b92b1e3acca
This was referenced Nov 20, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Across several modules, Gecode still requested zero bytes from the heap or a region, or passed null pointers with a zero element count to
memcpy. What a zero-byte allocation returns is implementation-defined, and passing a null pointer tomemcpyis undefined behavior in C and C++ even when the length is zero.This PR removes the remaining zero-size requests and null-pointer copies, then makes the heap contract explicit:
ActionorCHBcreated over an empty array keeps its shared storage so it remains initialized with size zero, copyable, and (forAction) still accepts decay updates, but it no longer allocates a zero-size element buffer or posts a recorder propagator.TupleSet,Archive,Space::rrealloc, the FlatZinc set and regular builtins, the example dictionary, DFA andTupleSet-from-DFA construction, andIntSetinitializer lists no longer make zero-byte requests or pass null pointers tomemcpy. Buffers that can now stay null are freed only when non-null; an empty initializer list constructs an emptyIntSet, and a FlatZincregularconstraint with a reversed final-state range treats the range as empty.Heapnow documents its size contract: allocation sizes must be positive,reallocmay grow from zero elements (whilerreallocno longer accepts zero), andcopyrequires non-null pointers even for zero elements. Debug builds assert the positive-size precondition inHeap::rallocandHeap::rrealloc.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.