Use this tag when your compiler is giving you "Unreachable code detected", "Unreachable statement" warning / error message for your code in question and you don't understand the reason.
Unreachable statements are codes that compilers detect as not reachable. There could be variety of situations when this happens.
Having a return statement in the middle of the code. The code that follows are considered as not reachable.
C# example:
string GetName()
{
string s = "abc";
return s;
s = s + "d"; // Warning CS0162: Unreachable code detected
return s;
}
Another, would be having a variable defined with certain value and then check the variable for different value to do some operations.
while (false)
{
Console.WriteLine("unreachable"); // Warning CS0162: Unreachable code detected
}
Java example:
public String getName()
{
String s = "abc";
return s;
s = s + "d"; // Unreachable statement
return s;
}
Compilers generally throw Warning message for these type of issues. But it depends on compiler to compiler. For instance .NET compiler may just throw warning but Java may throw it as error.