digitalmars.D.bugs - [Issue 20575] New: Version'ed cases in
- d-bugmail puremagic.com (55/55) Feb 11 2020 https://issues.dlang.org/show_bug.cgi?id=20575
https://issues.dlang.org/show_bug.cgi?id=20575 Issue ID: 20575 Summary: Version'ed cases in Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: moonlightsentinel disroot.org Consider the following example: void main() { import std.stdio; foreach (i; 1 .. 4) { write(i, ": "); switch (i) { version (A) case 1: version (B) case 2: write("Case"); break; case 3: default: write("Default"); } writeln(); } } Executing this example with different versions yields strange results: [ ]: // OK 1: Default 2: Default 3: Default [A]: // Strange 1: 2: Default 3: Default [B]: // Maybe? 1: Default 2: Default 3: Default [A, B]: // OK 1: Case 2: Case 3: Default [B] suggests that the missing A discards both case statements (which form a CaseRangeStatement) and hence executes the default. But [A] seems to discard "case 2: writeln(...);" without implicit fallthough / compiler warning. --
Feb 11 2020