www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14643] New: Safety violation with final switch and void


          Issue ID: 14643
           Summary: Safety violation with final switch and void
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: public dicebot.lv

This compiles:

enum E

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.

Jun 02 2015