[Issue 7835] switch case fallthrough error despite a break inside static foreach

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 6 10:17:27 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7835


bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |diagnostic
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |
            Summary|Ignored break inside static |switch case fallthrough
                   |foreach                     |error despite a break
                   |                            |inside static foreach


--- Comment #4 from bearophile_hugs at eml.cc 2012-04-06 10:18:05 PDT ---
Reopened, because you have missed the error message in my bug report.

Using a labeled break:


import core.stdc.stdio: printf;
template TypeTuple(TList...) {
    alias TList TypeTuple;
}
void main() {
    char c = 'b';
    MySwitch: switch (c) {
        case 'a': printf("1 a\n"); break;
        foreach (o; TypeTuple!('b', 'c')) {
            case o: printf("2 %c\n", c); break MySwitch;
        }
        default: printf("default");
    }
}


DMD 2.059 beta gives (compiling with -w):

test.d(12): Error: switch case fallthrough - use 'goto default;' if intended

I have also changed the issue title to better reflect the problem, now the
Keywords is 'diagnostic' because it's giving a warning where there is nothing
to warn against.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list