Thread overview
[Issue 15720] iota(long.max, long.min, step) does not work properly
Mar 20, 2016
Ender KaShae
March 20, 2016
https://issues.dlang.org/show_bug.cgi?id=15720

Ender KaShae <astrothayne@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |astrothayne@gmail.com

--- Comment #1 from Ender KaShae <astrothayne@gmail.com> ---
This happens because the operation to compute the length is

```
unsigned((start - stop) / -step)
```

but `long.max - long.min` overflows the long and results in -1.

The reason it works for a step of 1 is that -1 is cast to a ulong, which results in the maximum value of ulong (18446744073709551615).

Maybe this could be fixed by casting to the unsigned type before dividing by the step.

--
May 14, 2017
https://issues.dlang.org/show_bug.cgi?id=15720

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com

--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> ---
This might be fixed with the PR written for issue 16246 as the way the end condition is checked has changed (and length calc). Once it's merged, please re-check.

--
May 16, 2017
https://issues.dlang.org/show_bug.cgi?id=15720

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com

--- Comment #3 from Andrei Alexandrescu <andrei@erdani.com> ---
https://github.com/dlang/phobos/pull/5396/

--
May 16, 2017
https://issues.dlang.org/show_bug.cgi?id=15720

--- Comment #4 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/49ee158a9e5887ad835dc0f04c0309adf22ff965 Fix Issue 15720 - iota(long.max, long.min, step) does not work properly

https://github.com/dlang/phobos/commit/138d9b91284bba8da3ceb9e5da2f52fea85db1c9 Merge pull request #5397 from andralex/15720

Fix Issue 15720 - iota(long.max, long.min, step) does not work properly merged-on-behalf-of: Vladimir Panteleev <github@thecybershadow.net>

--
May 16, 2017
https://issues.dlang.org/show_bug.cgi?id=15720

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
June 17, 2017
https://issues.dlang.org/show_bug.cgi?id=15720

--- Comment #5 from github-bugzilla@puremagic.com ---
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/49ee158a9e5887ad835dc0f04c0309adf22ff965 Fix Issue 15720 - iota(long.max, long.min, step) does not work properly

https://github.com/dlang/phobos/commit/138d9b91284bba8da3ceb9e5da2f52fea85db1c9 Merge pull request #5397 from andralex/15720

--
January 05, 2018
https://issues.dlang.org/show_bug.cgi?id=15720

--- Comment #6 from github-bugzilla@puremagic.com ---
Commits pushed to dmd-cxx at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/49ee158a9e5887ad835dc0f04c0309adf22ff965 Fix Issue 15720 - iota(long.max, long.min, step) does not work properly

https://github.com/dlang/phobos/commit/138d9b91284bba8da3ceb9e5da2f52fea85db1c9 Merge pull request #5397 from andralex/15720

--