Lars Ivar Igesund wrote: > Don wrote: > >> [EMAIL PROTECTED] wrote: >>> http://d.puremagic.com/issues/show_bug.cgi?id=2423 >>> >>> Summary: Erroneous unreachable statement warning >>> Product: D >>> Version: 1.035 >>> Platform: Other >>> OS/Version: All >>> Status: NEW >>> Keywords: diagnostic >>> Severity: regression >>> Priority: P2 >>> Component: DMD >>> AssignedTo: [EMAIL PROTECTED] >>> ReportedBy: [EMAIL PROTECTED] >>> >>> >>> Consider the following function: >>> >>> void foo() { >>> >>> do { >>> if (false) >>> return 1; >>> } while (true); >>> } >>> >>> Compiling with -w, results in >>> >>> warning - whiletrue.d(6): Error: statement is not reachable >>> >>> Minimized from a module in Tango, meaning Tango does not compile with >>> warnings on. >>> >>> This regression was introduced in DMD 1.032. >>> >>> >> Why is that wrong? "return 1" looks unreachable to me. > > It is > > while(true) > > that is line 6 (you can move the while a few lines down to see that it > isn't just a line number error). The return makes the statement on that > line ("true" I assume) unreachable, which is correct without the > conditional. So it is the presence of the if (false) that makes this an > error. >
Of course, any conditional should remove this warning - in the module (tango/io/vfs/ZipFolder.d) where I found this problem, the return is in the else block. -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango
