[Issue 2423] Erroneous unreachable statement warning

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 26 11:35:52 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2423





------- Comment #4 from larsivar at igesund.net  2008-10-26 13:35 -------
(In reply to comment #3)
> (In reply to comment #0)
> > 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.
> > 
> 
> Erm, actually, I wonder if this is even valid.  do-while loops in D do not
> require a semicolon at the end.  The "unreachable statement" is simply the
> empty statement that follows the "while(true)".  The following code:
> 
> int foo() {
>    do {
>        return 1;
>    } while  (true)
> }
> 
> gives no warnings.
> 

You are right. I won't decide whether there is still a bug in the compiler, but
it is no longer a problem for Tango.


-- 



More information about the Digitalmars-d-bugs mailing list