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

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

Closed
LilithHafner opened this issue May 1, 2024 · 4 comments
Closed

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

LilithHafner opened this issue May 1, 2024 · 4 comments
Labels
kind:bug Indicates an unexpected problem or unintended behavior

Comments

@LilithHafner
Copy link
Member

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.

@LilithHafner LilithHafner added the domain:error messages Better, more actionable error messages label May 1, 2024
@LilithHafner
Copy link
Member Author

Oh, it's worse:

julia> x = Array{Int}(undef, -10, 10, 0)
-10×10×0 Array{Int64, 3}

@LilithHafner LilithHafner added kind:bug Indicates an unexpected problem or unintended behavior and removed domain:error messages Better, more actionable error messages labels May 1, 2024
@LilithHafner LilithHafner changed the title Inconsistent error messages when constructing arrays with negative first dimension It is possible to construct arrays with negative first dimension May 1, 2024
@LilithHafner LilithHafner added this to the 1.10 milestone May 1, 2024
@LilithHafner
Copy link
Member Author

This is broken on beta1 but works (throws) on master. Probably just need to find and backport the right PR.

@giordano
Copy link
Contributor

giordano commented May 1, 2024

Kinda duplicate of #54244, fixed by #54255

@LilithHafner
Copy link
Member Author

Exact duplicate of #54255 (comment)

@LilithHafner LilithHafner closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2024
@oscardssmith oscardssmith removed this from the 1.10 milestone May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants