www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22688] New: Control flow analysis is confused by goto case in

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

          Issue ID: 22688
           Summary: Control flow analysis is confused by goto case in loop
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: deadalnix gmail.com

See sample code:

int foo(char c) {
    while (true) {
        switch (c) {
            case 'a':
                goto default;

            default:
                return 3;
        }
    }
}


dmd gives an error:

Error: function `foo` no `return exp;` or `assert(0);` at end of function

As far as i can tell from experiments, dmd assumes that the "goto default"
statement may jump out of the loop. Or something like that.

--
Jan 18 2022