Is this a bug or not? (v1.7.0)
julia> UInt8(1):UInt8(12) |> collect
12-element Vector{UInt8}:
0x01
0x02
0x03
0x04
0x05
0x06
0x07
0x08
0x09
0x0a
0x0b
0x0c
julia> reverse(UInt8(1):UInt8(12)) |> collect
UInt8[]
Edit: Looks like it was.
opened 07:12PM - 09 Oct 18 UTC
closed 08:19PM - 06 Jan 22 UTC
bug
If you reverse a range of unsigned integers, then you get an empty range:
```
… julia> reverse(Int8(1):Int8(5)) |> collect
5-element Array{Int8,1}:
5
4
3
2
1
julia> reverse(UInt8(1):UInt8(5)) |> collect
0-element Array{UInt8,1}
```
Maybe this is intentional but it is not what one (I) would expect.
The problem seems to be that by reversing we get a `StepRange`
```
julia> reverse(UInt8(1):UInt8(5))
0x05:0xff:0x04
```
and apparently there is a check for an overflow here, so the values never get wrapped around through 2-complement.
versioninfo:
```
julia> versioninfo()
Julia Version 1.0.1
Commit 0d713926f8 (2018-09-29 19:05 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
JULIA_EDITOR = gvim
```
I can see that a fixed was merged to master, but how do I figure out which Julia release I need in order to fix this bug? Or do I need nightly?
How do you know which release includes the fix?
I see that the fix itself is here on Github:
JuliaLang:master
← JuliaLang:mb/reverseunsignedrange
opened 08:48PM - 29 Oct 18 UTC
Fixes #29576, ~works around~ improves #29810.
Edit: well, works around might … be a little strong. It changes a segfault to an inexact error, so this doesn't add support for reversing ranges of pointers (hence the lack of tests thereof).
Closes #42718
It says this was merged to master on January 7, 2022.
But if you compare v1.7.0 with v1.8.0-beta2 (the latest release) on Github here the newest addition is from May 2021. So it looks like the fix will not be included in 1.8.0 if I download the beta now, right?
1 Like
jling
March 25, 2022, 2:17am
#4
I see it, you just need to load a billion times towards the bottom of the webpage
2 Likes
Aha, they are in forward chronological order…