Bug 23604 – iota's floating point implementation does not conform to documentation

Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-01-07T02:32:50Z
Last change time
2024-12-01T16:40:58Z
Assigned to
No Owner
Creator
Ali Cehreli
Moved to GitHub: phobos#10512 →

Comments

Comment #0 by acehreli — 2023-01-07T02:32:50Z
The documentation at https://dlang.org/library/std/range/iota.html currently states "The two-argument overloads have step = 1. If begin < end && step < 0 or begin > end && step > 0 or begin == end, then an empty range is returned." However, the implementation for floating point types does not match documentation: import std; void test(T)() { assert(iota(T(1), T(2), T(-1)).empty); assert(iota(T(2), T(1)).empty); // By-default step==1 assert(iota(T(3), T(3)).empty); // By-default step==1 } void main() { test!int; // Produces empty ranges: GOOD test!double; // asserts: BAD } See the following thread for further discussion: https://forum.dlang.org/thread/[email protected]
Comment #1 by robert.schadek — 2024-12-01T16:40:58Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10512 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB