www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 148] New: Incorrect "statement is not reachable" warning with goto and for loop

reply d-bugmail puremagic.com writes:

           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 digitalmars.com
        ReportedBy: chris 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: ");
====== ======

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.

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

May 20 2006
parent d-bugmail puremagic.com writes:

bugzilla digitalmars.com changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

------- Comment #1 from bugzilla digitalmars.com  2006-06-04 22:15 -------
Fixed in DMD 0.160

Jun 04 2006