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 #33974, wrong integer types used in jl_array_sizehint #34005

Merged
merged 1 commit into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,8 @@ STATIC_INLINE void jl_array_shrink(jl_array_t *a, size_t dec)
if (a->flags.how == 0) return;

size_t elsz = a->elsize;
int newbytes = (a->maxsize - dec) * a->elsize;
int oldnbytes = (a->maxsize) * a->elsize;
size_t newbytes = (a->maxsize - dec) * a->elsize;
size_t oldnbytes = (a->maxsize) * a->elsize;
int isbitsunion = jl_array_isbitsunion(a);
if (isbitsunion) {
newbytes += a->maxsize - dec;
Expand Down Expand Up @@ -1107,7 +1107,7 @@ JL_DLLEXPORT void jl_array_sizehint(jl_array_t *a, size_t sz)
{
size_t n = jl_array_nrows(a);

int min = a->offset + a->length;
size_t min = a->offset + a->length;
sz = (sz < min) ? min : sz;

if (sz <= a->maxsize) {
Expand Down
11 changes: 11 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2657,3 +2657,14 @@ end
C = hcat(A, B)
@test typeof(C) == Array{Array{Float64,2},2}
end

# issue #33974
let n = 12000000, k = 257000000
# tests skipped since they use a lot of memory
@test_skip filter(x -> x[2] < 1.0, collect(enumerate(vcat(fill(0.5, n), fill(NaN, k)))))[end] == (n, 0.5)
@test_skip let v = collect(enumerate(vcat(fill(0.5, n), fill(NaN, k))))
resize!(v, n)
sizehint!(v, n)
v[end] == (n, 0.5)
end
end