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

BoundsError in MutableBinaryHeap delete! #611

Closed
ancapdev opened this issue Apr 27, 2020 · 1 comment · Fixed by #612
Closed

BoundsError in MutableBinaryHeap delete! #611

ancapdev opened this issue Apr 27, 2020 · 1 comment · Fixed by #612
Labels

Comments

@ancapdev
Copy link
Contributor

If run with --check-bounds=yes, the following throws BoundsError:

x = MutableBinaryMinHeap{Int}()
h1 = push!(x, 1)
h2 = push!(x, 2)
delete!(x, h2)

Offending line

        @inbounds nodes[nd_id] = new_rt = pop!(nodes)

Looks to happen when deleting from the end of the heap. The code is safe under the assumption that pop!(::Vector) doesn't resize underlying storage, but not ideal to have this throw when bounds checks are forced.

@oxinabox
Copy link
Member

Yes, the this is definately a bug.
Do you want to make a small PR to fix it, since you have found it now?

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 a pull request may close this issue.

2 participants