Bug 6067 – switch case fall through crash

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2011-05-28T04:36:00Z
Last change time
2011-05-28T06:38:50Z
Assigned to
nobody
Creator
r.k.persson

Comments

Comment #0 by r.k.persson — 2011-05-28T04:36:41Z
The following code crashes when run on dmd 2.053. windbg.exe stays on line "nop3" when debugged and then the program crashes. int main(string[] argv) { string a="test"; string b="dummy"; switch(b) { case "nop1": a="apples"; case "nop2": a="oranges"; case "nop3": a="bananas"; } return 0; }
Comment #1 by kennytm — 2011-05-28T05:11:01Z
Isn't it expected? A SwitchError will be thrown when there is no default: case and the switch doesn't match.
Comment #2 by bearophile_hugs — 2011-05-28T05:34:31Z
I suggest to compile D code with the -w compiler switch.
Comment #3 by r.k.persson — 2011-05-28T06:38:50Z
Ah! My c++ damaged brain thought it would fall through, but this behaviour is actually better!