Unconditional loop exists
monarch_dodra
monarchdodra at gmail.com
Tue Aug 13 08:07:06 PDT 2013
On Tuesday, 13 August 2013 at 14:56:32 UTC, bearophile wrote:
> Are situations like this, that are potential signs of
> bugs/mistakes, worth reporting with warnings?
>
>
> int foo() {
> // Unconditional 'break' within a loop:
> foreach (immutable _; 0 .. 10) {
> //...
> break;
> }
>
> // Unconditional 'return' within a loop:
> foreach (immutable _; 0 .. 10) {
> //...
> return 0;
> }
>
> assert(0);
> }
>
>
> Bye,
> bearophile
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.
More information about the Digitalmars-d
mailing list