By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,581 Members | 2,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,581 IT Pros & Developers. It's quick & easy.

Unreachable code detection error

P: n/a
What does that error mean and why would each break statement be marked as
unreachable? It implies the return will --always-- return some --thing-- if
even null and no further processing can possibly be done after the return
statement hence the break statement will not and can ever be reached?

switch (suffix)
{
case 1:
return "<sup>st</sup>";
break;
case 21:
return "<sup>st</sup>";
break;
case 31:
return "<sup>st</sup>";
...
}

Sep 1 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Sun, 31 Aug 2008 17:02:15 -0700, HillBilly <so******@somewhere.com>
wrote:
What does that error mean and why would each break statement be marked
as unreachable? It implies the return will --always-- return some
--thing-- if even null and no further processing can possibly be done
after the return statement hence the break statement will not and can
ever be reached?
Yes, that's exactly what it means. How could each "return" statement
return "null" given that in each case you have a string literal? And even
if it could, why would the value it returns affect whether flow can
continue past the "return" statement?

The compiler is correctly telling you that you have "break" statements
that are unreachable. No possible configuration of input could lead to
that code being executed. That's what "unreachable" means.

Pete
Sep 1 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.