JuliaLinearAlgebra / ArrayLayouts.jl

A Julia package for describing array layouts and more general fast linear algebra
https://julialinearalgebra.github.io/ArrayLayouts.jl/
MIT License
56 stars 10 forks source link

Avoid overflow in indexing and sum #217

Closed jishnub closed 7 months ago

jishnub commented 7 months ago

Avoid overflows in indexing a RangeCumsum by being careful with factors.

On master

julia> r = RangeCumsum(typemax(Int) .+ (0:0))
1-element RangeCumsum{Int64, UnitRange{Int64}}:
 9223372036854775807

julia> sum(r)
-1

This PR

julia> sum(r)
9223372036854775807
codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 89.77%. Comparing base (4aa8264) to head (f2550c3). Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #217 +/- ## ========================================== + Coverage 89.58% 89.77% +0.19% ========================================== Files 11 11 Lines 1844 1859 +15 ========================================== + Hits 1652 1669 +17 + Misses 192 190 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.