Bug 20216 – Switch case fall-through not detected for multiple case arguments
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-09-16T11:36:10Z
Last change time
2024-10-23T10:45:01Z
Keywords
accepts-invalid
Assigned to
uplink.coder
Creator
David Eckardt
Comments
Comment #0 by david.eckardt — 2019-09-16T11:36:10Z
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
--
Comment #1 by david.eckardt — 2019-09-16T11:43:49Z
This applies to DMD 2.086.1 as well.
Comment #2 by simen.kjaras — 2019-09-16T11:47:48Z
Applies to all DMD since at least 2.060, so unlikely to be a regression. :p
Comment #3 by uplink.coder — 2019-09-18T16:28:06Z
This happens because multi cases get nested.
To see it add -vcg-ast.
I'll see if I can fix it.
However from reading the compiler source it seems intended....
Comment #4 by dkorpel — 2024-10-23T10:45:01Z
*** This issue has been marked as a duplicate of issue 22999 ***