Skip to content

append!(Int64[], [1.1, 0.1]) results in unwanted array growth #15868

@gasagna

Description

@gasagna

Consider the following code demonstrating the bug in append!

julia> a = Int64[]
0-element Array{Int64,1}

julia> append!(a, [1.1, 2.2])
ERROR: InexactError()
 in copy! at abstractarray.jl:344
 in append! at array.jl:447

julia> a
2-element Array{Int64,1}:
 13128344792
  4521590816

Now, in this case the program terminates with an error, but if the append statement is within a try/catch block the growth of the array can go unnoticed.

I actually discovered this bug in testing code, where I was testing that some code involving an append! raised an appropriate error. As soon as I added this test, all other tests in my code started to fail miserably.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]needs decisionA decision on this change is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions