www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20216] New: Switch case fall-through not detected for

https://issues.dlang.org/show_bug.cgi?id=20216

          Issue ID: 20216
           Summary: Switch case fall-through not detected for multiple
                    case arguments
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: david.eckardt frequenz.com

DMD 2.087.1 allows implicit switch case fall-through for cases with multiple
arguments.

--
import std.stdio;

int x = 1;

switch (x)
{
    case 1, 2: writeln("1/2");
    // jump/throw/assert(false) missing, should not compile

    case 3, 4: writeln("3/4");
    // jump/throw/assert(false) missing, should not compile

    default: writeln("default");
}
--

compiles and outputs

--
1/2
3/4
default
--

--
Sep 16 2019