[Issue 16549] Switch statement can skip initialization

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Sep 26 23:51:41 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16549

--- Comment #1 from Jacob Carlborg <doob at me.com> ---
Here's a very similar case where it fails to initialize "foo" as well:

import std.stdio;

struct State {}

State bar(int jumpLabel)
{
    switch (jumpLabel)
    {
        int foo;
        case 0:
        writeln(foo);

        default:
        break;
    }

    return State();
}

void main()
{
    auto state = bar(0);
}

--


More information about the Digitalmars-d-bugs mailing list