www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18227] New: Assertion failure in iota for floating point

https://issues.dlang.org/show_bug.cgi?id=18227

          Issue ID: 18227
           Summary: Assertion failure in iota for floating point
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: briancschott gmail.com

std.range.package.iota has a bug in how it calculates the number of steps to
take. The following inputs cause a to!size_t() to round a 999.9999999 down 
instead of up to 1000, which then causes an assert failure.

-------------------------
import std.range;

void main()
{
    iota(8.5300000000000011, 438.17803623529841, 0.4296480362352984);
}
-------------------------
$ rdmd test.d
core.exception.AssertError /home/brian/.dvm/compilers/dmd-2.078.0/linux/bin/../../src/phobos/std/range/package.d(5594):
Assertion failure
----------------
??:? _d_assertp [0x96e25d65]
??:? pure ref  safe std.range.iota!(double, double, double).iota(double,
double, double).Result std.range.iota!(double, double, double).iota(double,
double, double).Result.__ctor(double, double, double) [0x96e252fe]
??:? pure  safe std.range.iota!(double, double, double).iota(double, double,
double).Result std.range.iota!(double, double, double).iota(double, double,
double) [0x96e251c0]
??:? _Dmain [0x96e250e7]

--
Jan 11 2018