[Issue 13858] New: Wrong warning about unreachable code with break/goto case

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Dec 12 01:07:05 PST 2014


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 at puremagic.com
          Reporter: andrej.mitrovich at 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 at test.d(1): Assertion failure

--


More information about the Digitalmars-d-bugs mailing list