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

pdep failure #18

Open
drtconway opened this issue Aug 11, 2023 · 0 comments
Open

pdep failure #18

drtconway opened this issue Aug 11, 2023 · 0 comments

Comments

@drtconway
Copy link

drtconway commented Aug 11, 2023

Great library, thanks for making it!

I am writing succinct data structure code using pdep to implement select on 64-bit words:

pub fn select64(x: u64, idx: usize) -> u64 {
    (1u64 << idx).pdep(x).trailing_zeros() as u64
}

However, the following test is failing:

fn test_select64_2() {
    let x:u64 = 18446744073709551615u64;
    assert_eq!(select64(x, 0), 0);
}

Note that x is 111....111 (i.e. -1).

The error message I'm seeing is:

thread 'words::tests::test_select64_2' panicked at 'attempt to add with overflow', /<path-to-my-home-directory>/.cargo/registry/src/github.com-1ecc6299db9ec823/bitintr-0.3.0/src/pdep.rs:107:17

I'm willing to be convinced that my code is somehow bad, but I think this might be a bug in the library. I'm on an X86_64 Mac.

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

No branches or pull requests

1 participant