www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16549] New: Switch statement can skip initialization


          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)
        int foo;
        case 0:
        assert(foo == foo.init);


void main()

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