is it bug?

Ali Çehreli acehreli at yahoo.com
Thu Apr 4 07:24:02 PDT 2013


On 04/04/2013 06:27 AM, Alexandr Druzhinin wrote:
> on win7 64 bits using dmd 2.062 32 bits this code http://dpaste.dzfl.pl
> /6cca43b5 failed with assert failure:
> core.exception.AssertError at std.range(5288): Assertion failure
> but on ubuntu 12.04 64 bits, dmd 2.062 64 bit it compiles and works
> rather well. May be I missed something important with it?

The problem is reproducible on Linux as well if you compile with -m32.

The following assert fails in range.d:

   assert(start + count * step >= end);

start: 0
count: 83
step: 12.0386
end: 999.2

Even though count * step is seemingly 999.2 as well, due to the inexact 
nature of floating point calculations the assertion is false.

The problem seems to be in your code because your step calculation 
ignores a remainder. This works:

     // OLD: step = width / factor;
     step = (width  + factor - 1) / factor;

Ali



More information about the Digitalmars-d-learn mailing list