[Issue 21739] New: debug case can access variable from other case

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 21 02:24:37 UTC 2021


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

          Issue ID: 21739
           Summary: debug case can access variable from other case
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: moonlightsentinel at disroot.org

Consider the following code:

void main()
{
    int i;
    switch (i)
    {
        case 0:
            int x;
            break;

        case 1:
            x = 1;
            break;

        case 2:
            int y;
            break;

        debug
        {
            case 3:
                y = 1; // Accepted
                break;
        }

        default:
    }
}

DMD rightfully complains that `case 1:` cannot see x but accepts `case 3:`
accessing y.

--


More information about the Digitalmars-d-bugs mailing list