Summary: enum doesn't work as the increment in a for loop
           Product: D
           Version: 2.031
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD

The following should print a list of numbers from 0 to 10:

    enum real ONE = 1.0;
    real x;
    for (x=0.0; x<10.0; x+=ONE)  writeln(x);

Instead it prints:


I.e. the loop is only executed once, and x is set to NaN after the first
iteration. The same happens if float is used instead of real. If double is
used, the program goes into a near-infinite loop, spitting out very small
numbers (starting with 6.65345e-316).

The following makes the program behave as expected:
  - making ONE a normal variable instead of an enum
  - writing "enum { real ONE }" instead
  - putting the increment inside the loop body

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to