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

          Issue ID: 14643
           Summary: Safety violation with final switch and void
                    initializer
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: [email protected]
          Reporter: [email protected]

This compiles:

```
enum E
{
    A,
    B
}

int* foo() @safe
{
    E value = void;
    static int a, b;

    final switch (value)
    {
        case E.A: return &a;
        case E.B: return &b;
    }
}

void main() @safe
{
    *foo() = 43;
}
```

Throws core.exception.SwitchError in normal mode but crashes in release mode by
trying to write via garbage pointer.

--

Reply via email to