Skip to content

Conversation

whisk
Copy link
Contributor

@whisk whisk commented Aug 3, 2025

Description

UnionCardinality, IntersectionCardinality, DifferenceCardinality, SymmetricDifferenceCardinality panic on an empty bitset with "index out of range". Minimal example:

a := New(0)
b := New(0)
_ = a.UnionCardinality(b)

panic is "commutative", i.e. a and b may be swapped.

Fix

Remove all _ = m[len(s)-1] // BCE in popcnt*Slice functions introduced in #203.

Additionally, I wasn't able to reproduce any gain in inlining cost, but this might be due to the different go version I use (1.24).

@whisk whisk changed the title fixed popcntMaskSlice, popcntAndSlice, popcntOrSlice, popcntXorSlice … fixed UnionCardinality panic on empty bitsets Aug 3, 2025
@lemire lemire merged commit e90b4c8 into bits-and-blooms:master Aug 4, 2025
27 checks passed
@lemire
Copy link
Member

lemire commented Aug 4, 2025

I have merged but your PR breaks BCE. I will reintroduce it in a later commit.

inlining cost

BCE is not the same as inlining. I don't care about inlining. I care about BCE.

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.

2 participants