www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15535] New: Emit error on "goto default" in final switch


          Issue ID: 15535
           Summary: Emit error on "goto default" in final switch
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: goejendaagh zonnet.nl

This code compiles, but I think it shouldn't:

void main()
    int i;
    final switch(i) {
        case 1: goto default;

When executed, the program immediately crashes.
Because a final switch cannot have a "default:" case, I think the compiler
error on this code.

Jan 09 2016