www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13858] New: Wrong warning about unreachable code with

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

          Issue ID: 13858
           Summary: Wrong warning about unreachable code with break/goto
                    case
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

-----
void foo() { assert(0); }

void main()
{
    int x = 0;

    LSwitch: switch (x)
    {
        case 0:
            break LSwitch;

        default: return;
    }

    foo();
}
-----

$ dmd -w -run test.d
 test.d(15): Warning: statement is not reachable
However the above isn't true: $ dmd -run test.d
 core.exception.AssertError test.d(1): Assertion failure
--
Dec 12 2014