[Issue 15731] New: Analysis error on explicit case fall-through

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Feb 27 05:10:38 PST 2016


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

          Issue ID: 15731
           Summary: Analysis error on explicit case fall-through
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: jbc.engelen at gmail.com

The following code compiles fine without explicit fall-through, but with
-version=bad it errors.

int hexStringConstant(dchar* p)
{
    while (1)
    {
        dchar c = *p++;
        switch (c)
        {
        case ' ':
        case '\t':
        case '\v':
        case '\f':
            continue;
        case '\r':
            if (*p == '\n')
                continue;
            version(bad)      /// <-- Look here
              goto case;
        case '\n':
            continue;
        case 0:
        case 0x1A:
            return 111;
        case '"':
            return 222;
        default:
            break;
        }
    }
}

> dmd -c bug.d
[ no problem ]

> dmd -c bug.d -w
bug.d(18): Warning: switch case fallthrough - use 'goto case;' if intended

> dmd -c bug.d -version=bad
bug.d(1): Error: function bug.hexStringConstant no return exp; or assert(0); at
end of function

--


More information about the Digitalmars-d-bugs mailing list