Strange behaviour of enums in for loops

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Fri Jul 17 05:33:36 PDT 2009


Lars T. Kyllingstad wrote:
> I've found what I believe to be a pretty serious bug in DMD (I've tried 
> it with DMD 2.031):
> 
>    enum real ONE = 1.0;
>    for (real x=0.0; x<=10.0; x+=ONE)  writeln(x);
> 
> The above loops only once, printing "0".


By the way: x becomes NaN after the first iteration, which is why the 
loop ends.

-Lars



More information about the Digitalmars-d mailing list