Skip to content

Bug with range() and unsigned indices #44895

Closed
@gerw

Description

@gerw

The snippet

x = range(-1,1,length=11)
x[UInt(1)]

gives 3.6893488147419105e18 instead of the expected -1.0.

The problem seems to be

u = i - r.offset
, since UInt(1) - 6 underflows.

julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorcorrectness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingrangesEverything AbstractRange

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions