Bug 22719 – Fallthrough detection falls through.

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-01-31T13:54:35Z
Last change time
2024-12-13T19:20:41Z
Assigned to
No Owner
Creator
deadalnix
Moved to GitHub: dmd#20045 →

Comments

Comment #0 by deadalnix — 2022-01-31T13:54:35Z
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.
Comment #1 by robert.schadek — 2024-12-13T19:20:41Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20045 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB