Skip to content

It is possible to construct arrays with negative first dimension #54325

Closed
@LilithHafner

Description

@LilithHafner

Normally, invalid array sizes are caught by Core.checked_dims, but Core.checked_dims(-10, 10, 10) does not throw, leading to this error

julia> Array{Int}(undef, -10, 10, 10)
ERROR: ArgumentError: invalid GenericMemory size: too large for system address width
Stacktrace:
 [1] GenericMemory
   @ ./boot.jl:514 [inlined]
 [2] new_as_memoryref
   @ ./boot.jl:536 [inlined]
 [3] Array
   @ ./boot.jl:583 [inlined]
 [4] (Array{Int64})(::UndefInitializer, m::Int64, n::Int64, o::Int64)
   @ Core ./boot.jl:596
 [5] top-level scope
   @ REPL[64]:1

When "ERROR: ArgumentError: invalid Array dimensions" is more common. We should, at the very least, put an inline comment in the 3+ arg Core.checked_dims method that notes this gap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]bugIndicates an unexpected problem or unintended behaviorduplicateIndicates similar issues or pull requests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions