Bug 148 – Incorrect "statement is not reachable" warning with goto and for loop

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-05-20T02:31:00Z
Last change time
2014-02-15T13:22:24Z
Assigned to
bugzilla
Creator
chrisp

Comments

Comment #0 by chrisp — 2006-05-20T02:31:32Z
====== 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;
Comment #1 by bugzilla — 2006-06-04T22:15:47Z
Fixed in DMD 0.160