------- Comment #2 from [EMAIL PROTECTED]  2008-10-26 12:27 -------
(In reply to comment #1)
> There is also a related issue that will show in the same function if that has 
> a
> return value:
> int foo() {
>     do {
>         return 1;
>     } while  (true);
> }
> warning - whiletrue.d(4): Error: statement is not reachable
> warning - whiletrue.d(1): function no return at end of function
> I understand that the "no return" is a semantic challenge, but the rule is
> fairly simple: if there is a while(true), then all code after it is dead code
> unless there is also a break. This is also a regression.
> Note that whereas the first is an obvious bug and impossible to workaround,
> this one is possible to workaround, but still a question about quality of
> implementation. The "no return" bug does also affect/break Tango when using
> warnings.

In this case there's no doubt a simple flow analysis will take care of things.
The challenge is only when conditions are complex; in this case that doesn't
matter. The code could as well be:

do {
    return 1;
} while (P == NP);

My explanation for the bug is that Walter's front-end rewrites loops with
terminal test as loops with initial test with a jump:

do stmt while (cond); 


goto __label; while (cond) __label: stmt

The rewritten form makes it a tad more difficult to figure out what's going on.



Reply via email to