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

unordered_base: Fix corner case in bucket computation #22

Merged
merged 1 commit into from
Nov 19, 2019

Conversation

stotko
Copy link
Owner

@stotko stotko commented Nov 19, 2019

If Fibonacci Hashing is used, the result of the bucket function may exceed the bucket count in case of a bucket count of 1. This is due to a bit shift by 64 that will be performed in this case which leads to undefined/unreliable behavior. Handle this corner case by explicitly returning the only possible bucket position, i.e. return 0 in this case. Furthermore, use std::size_t instead of size_t to improve the consistency.

@stotko stotko merged commit 411aa71 into master Nov 19, 2019
@stotko stotko deleted the unordered_base_hashing_fix branch November 19, 2019 11:27
@stotko stotko added the bug label Dec 11, 2019
@stotko stotko added this to the 1.1.0 milestone Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant