www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15731] New: Analysis error on explicit case fall-through

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 puremagic.com
          Reporter: jbc.engelen 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 --
Feb 27 2016