digitalmars.D.bugs - [Issue 16549] New: Switch statement can skip initialization
- via Digitalmars-d-bugs (37/37) Sep 26 2016 https://issues.dlang.org/show_bug.cgi?id=16549
https://issues.dlang.org/show_bug.cgi?id=16549 Issue ID: 16549 Summary: Switch statement can skip initialization Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: doob me.com Compiling and running the following code will trigger the assertion since "foo" is not initialized: struct State { int jumpLabel; } void bar(State s) { switch(s.jumpLabel) { int foo; case 0: assert(foo == foo.init); default: break; } } void main() { bar(State(0)); } It seems like it's the struct that is fooling the compiler. If it's replaced with a plain int, "foo" will be initialized. --
Sep 26 2016