[Issue 2423] Erroneous unreachable statement warning
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Oct 26 10:52:48 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2423
------- Comment #3 from jarrett.billingsley at gmail.com 2008-10-26 12:52 -------
(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.
--
More information about the Digitalmars-d-bugs
mailing list