[Bug 148] New: Incorrect "statement is not reachable" warning with goto and for loop

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 20 00:31:33 PDT 2006


http://d.puremagic.com/bugzilla/show_bug.cgi?id=148

           Summary: Incorrect "statement is not reachable" warning with goto
                    and for loop
           Product: D
           Version: 0.157
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: chris at inventivedingo.com


====== testbug.d =======
import std.stdio, std.string;

void main() {
        int i=0;
        writef("This number is zero: ");
        goto inloop;
        for(; i<10; i++) {              // this is line 7
                writef("This number is nonzero: ");
inloop:
                writefln(toString(i));
        }
}
====== ======

D:\D>dmd testbug.d -w
warning - testbug.d(7): statement is not reachable

========
A warning is generated on the line of the for loop, but that statement will of
course will be executed when the loop loops.

Workarounds:
- Compile without warnings
- Change line 6 to: if (1) goto inloop;


-- 




More information about the Digitalmars-d-bugs mailing list