Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean last word of target bitset after using Copy. #113

Merged

Conversation

steampoweredtaco
Copy link
Contributor

Description

This PR will use the existing cleanLastWord when copying a bitset to keep the invariant other functions depend on, such as Count, that no bits are set past the length of the bitmask on the last uint64 word.

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #112

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

A new TestCopyUnaligned unit test has been added which verifies that a new bitmask copy that isn't aligned on a 64 bit copies from a bitmask that is larger, but only by less than a uint64 word, that Count and the set bits in the copy are correct. Without the change, this test will fail where the targets Count() would be > than the length of the target.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • (NA) I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • (NA) Any dependent changes have been merged and published in downstream modules

@lemire
Copy link
Member

lemire commented Oct 27, 2022

Running tests.

@lemire
Copy link
Member

lemire commented Oct 27, 2022

Merging.

@lemire lemire merged commit e4f40f1 into bits-and-blooms:master Oct 27, 2022
@steampoweredtaco steampoweredtaco deleted the fix-copy-overflow-bits branch October 27, 2022 18:52
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.

Count() can be wrong when used on a copied bitset.
2 participants