digitalmars.D.bugs - [Issue 22719] New: Fallthrough detection falls through.
- d-bugmail puremagic.com (53/53) Jan 31 2022 https://issues.dlang.org/show_bug.cgi?id=22719
https://issues.dlang.org/show_bug.cgi?id=22719 Issue ID: 22719 Summary: Fallthrough detection falls through. Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: deadalnix gmail.com Sample code: import std.stdio; void foo() { writeln(__FUNCTION__); } void bar() { writeln(__FUNCTION__); } void fun(int i) { int n = 3; switch (i) { while (n --> 0) case 0: case 1: foo(); bar(); default: writeln("default"); } } void main() { fun(1); } The fun function ought to be parsed as: void fun(int i) { int n = 3; switch (i) { while (n --> 0) { case 0: case 1: foo(); bar(); } default: writeln("default"); } } The control flow falls through into the default case without a goto default. This is supposed to be an error in D, but DMD accepts it in this case. --
Jan 31 2022