www.digitalmars.com         C & C++   DMDScript  

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


          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':
        case '\r':
            if (*p == '\n')
            version(bad)      /// <-- Look here
              goto case;
        case '\n':
        case 0:
        case 0x1A:
            return 111;
        case '"':
            return 222;

 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