Bug 10121 – Declarations before first case level in switch statement are allowed

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-19T12:32:00Z
Last change time
2015-06-09T05:15:09Z
Keywords
accepts-invalid, wrong-code
Assigned to
nobody
Creator
maxim

Comments

Comment #0 by maxim — 2013-05-19T12:32:41Z
extern(C) int printf(const char*, ...); void main() { switch(0) { int a = 4; // if immutable, prints 4 case 0: printf("%d\n", a); //prints 0 } } After the switch there is jump to zero case without proper initialization of 'a'.
Comment #1 by bearophile_hugs — 2013-05-19T16:12:50Z
Dupe of Issue 3820 ?
Comment #2 by maxim — 2013-05-19T21:09:14Z
(In reply to comment #1) > Dupe of Issue 3820 ? Yes. *** This issue has been marked as a duplicate of issue 3820 ***