www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23266] New: Dead else blocks are not considered unreachable

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

          Issue ID: 23266
           Summary: Dead else blocks are not considered unreachable
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

This code, built with -w, gives a "statement is not reachable" warning on the
second return:

void main() {
    if (true) return;
    return;
}

This code does not:

void main() {
    if (true) return;
    else return;
}

This despite the else block being just as unreachable.

--
Jul 22 2022