www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9642] New: Missed switch case fallthrough

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9642

           Summary: Missed switch case fallthrough
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



void main() {
    int x;
    switch ('x') {
        case 'a':
            x++;
        case 'b': .. case 'c':
            x++;
            break;
        default:
    }
}



With dmd 2.063alpha it compiles with no errors nor warnings. But I think it
should give an error like:

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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 03 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9642


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



17:34:42 PST ---
It looks like it wasn't properly implemented, e.g. this will error with -w:

void main() {
    int x;
    switch ('x') {
        case 'a':
            x++;
        case 'b':// .. case 'c':
            x++;
            break;
        default:
    }
}

Note the commented out code. Tested in 2.063 -- 2.060.

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