Unreachable code detected
-
Well, you wouldn't want it to fall through, would you?
Well, on a X86, you'd need at 3 bit errors on the instruction to convert a RET (0xC2) to a NOP (0x90), but hey, I'm all for defensive programming! Marc
Imperative to Functional Programming Succinctly Higher Order Programming
-
So, I just compiled a small web service that I, of course, did not write. Got almost 100 "Unreachable code detected" errors. Why? Here's an example:
case [some case]:
return CallSomeFunction(xmldata);
break;:rolleyes: Marc
Imperative to Functional Programming Succinctly Higher Order Programming
-
# pragma warning disable
-
So, I just compiled a small web service that I, of course, did not write. Got almost 100 "Unreachable code detected" errors. Why? Here's an example:
case [some case]:
return CallSomeFunction(xmldata);
break;:rolleyes: Marc
Imperative to Functional Programming Succinctly Higher Order Programming
-
So, I just compiled a small web service that I, of course, did not write. Got almost 100 "Unreachable code detected" errors. Why? Here's an example:
case [some case]:
return CallSomeFunction(xmldata);
break;:rolleyes: Marc
Imperative to Functional Programming Succinctly Higher Order Programming
wouldn't those be warnings? are is "warnings as errors" turned on?
If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein -
wouldn't those be warnings? are is "warnings as errors" turned on?
If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert EinsteinTheGreatAndPowerfulOz wrote:
wouldn't those be warnings? are is "warnings as errors" turned on?
They are warnings. I hate warnings. Warnings should be fixed, even if their not treated as errors by the IDE. Marc
Imperative to Functional Programming Succinctly Higher Order Programming
-
TheGreatAndPowerfulOz wrote:
wouldn't those be warnings? are is "warnings as errors" turned on?
They are warnings. I hate warnings. Warnings should be fixed, even if their not treated as errors by the IDE. Marc
Imperative to Functional Programming Succinctly Higher Order Programming
agreed
If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein -
So, I just compiled a small web service that I, of course, did not write. Got almost 100 "Unreachable code detected" errors. Why? Here's an example:
case [some case]:
return CallSomeFunction(xmldata);
break;:rolleyes: Marc
Imperative to Functional Programming Succinctly Higher Order Programming
When I started programming, structured programming was all the rage, and one of its fundamental principles was "single entry, single exit" for every block of code. While structured programming in no longer a primary development paradigm, it's principles are still valid. Putting a
return
inside acase
is the Devil's work.Software Zen:
delete this;
-
TheGreatAndPowerfulOz wrote:
wouldn't those be warnings? are is "warnings as errors" turned on?
They are warnings. I hate warnings. Warnings should be fixed, even if their not treated as errors by the IDE. Marc
Imperative to Functional Programming Succinctly Higher Order Programming
Amen to that, I use code analysis tools to and eliminate all the issues those detect. Occassionally I have to use a pragma/code comment when I really intentionally did something, but its rare, and worth it for the number of bugs I detect early.
"If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.
-
When I started programming, structured programming was all the rage, and one of its fundamental principles was "single entry, single exit" for every block of code. While structured programming in no longer a primary development paradigm, it's principles are still valid. Putting a
return
inside acase
is the Devil's work.Software Zen:
delete this;
I fundamentally disagree, but it does depend on the language. In C++ and many other languages I use RAII instead to ensure nothing is ever missed.
"If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.