Repository navigation
Fix RemoveRange for out-of-domain starts - #601
Merged
lemire merged 1 commit intoDec 1, 2026
Merged
Conversation
Signed-off-by: Perfloop Agent <[email protected]>
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.
Effect: silent wrong results. The call returns normally and deletes stored values outside the requested range; no error or panic.
Since: the end clamp added in 4a6b95e (the fix for #141) runs after the empty-range check and before
rangeStartis narrowed touint32. That has been the case in every release since v0.4.2 (2018-02-06), through the current v2.30.0 (2026-10-19).From a checkout at
340bdf64f4bf3d3367950d9ae37b15cb5003b269, run:Expected:
Actual:
RemoveRangechecks whether the interval is empty before clamping its upper bound to0x100000000. It then narrows the start touint32, wrapping this example's start to zero and removing every stored value. A larger start removes every value at or aboverangeStart mod 2^32.This change returns immediately when the start exceeds
MaxUint32, before narrowing it. It retains the existing upper-bound clamping for representable starts.TestRemoveRangeOutsideDomaininroaring_test.gocovers out-of-domain starts, and the existing range-end test now ensuresMaxUint32itself remains removable.This matches
IntersectsWithInterval, which already returns early for a start aboveMaxUint32.CardinalityInRangehas the same check order; open PR #600 fixes it there.The focused Go range-removal and copy-on-write tests passed for the 32-bit API, its 64-bit caller, and the generic fallback; the new test fails without the fix.
Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart.