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

Fix integer overflow in reverse! #45871

Merged
merged 3 commits into from
Jun 30, 2022
Merged

Fix integer overflow in reverse! #45871

merged 3 commits into from
Jun 30, 2022

Conversation

jishnub
Copy link
Contributor

@jishnub jishnub commented Jun 30, 2022

Move midpoint from Base.Sort to Base and use it to avoid integer overflow. Now

julia> vo = OffsetArray([1:4;], typemax(Int)-4)
4-element OffsetArray(::Vector{Int64}, 9223372036854775804:9223372036854775807) with eltype Int64 with indices 9223372036854775804:9223372036854775807:
 1
 2
 3
 4

julia> reverse!(vo)
4-element OffsetArray(::Vector{Int64}, 9223372036854775804:9223372036854775807) with eltype Int64 with indices 9223372036854775804:9223372036854775807:
 4
 3
 2
 1

Fixes #45870

@vtjnash vtjnash merged commit 3c04919 into JuliaLang:master Jun 30, 2022
@fredrikekre fredrikekre added backport 1.6 Change should be backported to release-1.6 backport 1.7 backport 1.8 Change should be backported to release-1.8 labels Jun 30, 2022
@jishnub jishnub deleted the reversefix branch July 1, 2022 01:09
KristofferC pushed a commit that referenced this pull request Jul 6, 2022
KristofferC pushed a commit that referenced this pull request Jul 6, 2022
@KristofferC KristofferC removed the backport 1.8 Change should be backported to release-1.8 label Jul 8, 2022
pcjentsch pushed a commit to pcjentsch/julia that referenced this pull request Aug 18, 2022
KristofferC pushed a commit that referenced this pull request Dec 21, 2022
(cherry picked from commit 3c04919)
KristofferC pushed a commit that referenced this pull request Dec 21, 2022
(cherry picked from commit 3c04919)
KristofferC pushed a commit that referenced this pull request Dec 21, 2022
(cherry picked from commit 3c04919)
KristofferC pushed a commit that referenced this pull request Dec 21, 2022
(cherry picked from commit 3c04919)
staticfloat pushed a commit that referenced this pull request Dec 23, 2022
KristofferC pushed a commit that referenced this pull request Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.6 Change should be backported to release-1.6
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integer overflow in reverse! for an OffsetArray
4 participants