www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22930] New: importC: switch statement gives bogus unreachable

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

          Issue ID: 22930
           Summary: importC: switch statement gives bogus unreachable code
                    warning
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: duser neet.fi
                CC: duser neet.fi

with "dmd -wi":

int fn()
{
        switch (1)
        {
                case 2:
                        return 0;
        }
        return 0; // Warning: statement is not reachable
}

seems like any switch that doesn't have at least once case using break; or
falling of the end will give this warning for code after it

--
Mar 25 2022