Unconditional loop exists

bearophile bearophileHUGS at lycos.com
Tue Aug 13 08:26:06 PDT 2013


monarch_dodra:

> Arguably, D has the "unreachable code" warning, so an 
> unconditional break would short circuit the incrementation code.
>
> So I think there is no need for a "new" warning for this, but 
> to make it detect that a certain amount of code is not 
> reachable.

The D compiler gives a warning if you add code after those return 
and break. So the missing warning is useful when those return and 
break are at the end of the loop body.

That assert(0) is needed because D doesn't deduce that return is 
always executed.

Bye,
bearophile


More information about the Digitalmars-d mailing list