Is there ANY chance we can fix the bitwise operator precedence

bearophile bearophileHUGS at lycos.com
Sat Jun 19 02:56:41 PDT 2010


KennyTM~:
> This "fallthrough" statement already exists.
> 
>      switch (x) {
>         case 0:
>           do_something();
>           goto case;
>         case 1:
>           do_more_thing();
>           goto case;
>         case 2:
>           done();
>           break;
>         default:
>           error();
>           break;
>      }

I didn't know this, this is a hidden D feature. So it's just a matter of D forbidding the cases that miss an explicit return, goto, or break, assert(0), exit(), and similar.

As for the multiple returns in a function this needs a bit of care because this is acceptable:

switch (x) {
    case 0:
        if (y)
            goto case;
        else
            return x;
    default:
        break;
}

Bye,
bearophile


More information about the Digitalmars-d mailing list