Questions tagged [unreachable-code]

Unreachable code is part of the source code of a program which can never be executed because there exists no control flow path to the code from the rest of the program.

181 questions
1
vote
4 answers

Unreachable code- try-catch-finally

I know if java finds a line of code where it's guaranteed that control will never reach, then compiler reports unreachable code error. consider following code. static int method1() { try{ return 1; } catch(Exception e){ } //…
Deepankar Singh
  • 662
  • 1
  • 9
  • 20
1
vote
1 answer

Unreachable Code Warning in Static EventHandler callback

We have an interesting issue occurring that I wonder if anyone may be able to shed light on. We are currently seeing the warning: "Method never reaches end or 'return' statement" on an event handler delegate callback that is rather odd. Consider…
Evan L
  • 3,805
  • 1
  • 22
  • 31
1
vote
3 answers

error (Unreachable Code) in calling variable

I'm trying to make a program that lets the user to input 10 integers, and then calculate the average of that integers. I got Unreachable code error in System.out.println("average : " + average); line. I already try to make a new class and call the…
bnrfly
  • 155
  • 1
  • 2
  • 11
1
vote
1 answer

if / endif "Unreachable code detected" in C#

Everything runs fine locally, but I'm getting an "Unreachable code detected" error. Here is that piece of code: private string GetRedirectUriForCurrentConfiguration() { #if (DEBUG || DebugDev) return "http://localhost:1855/"; #endif …
1
vote
2 answers

Issue with Unreachable Code Detected (but I need to yield return somewhere)

issue is as follows. I'm making a variant of a typing game, my issue is that I need to loop through my char array and check to see if the user is hitting the right key or not (introducing the requirement to wait for user input). When the right key…
WerdaFerk
  • 57
  • 1
  • 8
1
vote
2 answers

Why are the last two instructions unreachable code?

Eclipse spots them as unreachable code, which apparently is a code that will never be read for there's no path to reach it, but I don't see why. The instructions are inside a main() method //leemos FileInputStream fis; ObjectInputStream…
Artur Alvaro
  • 115
  • 8
1
vote
1 answer

Unreachable code when overriding Object.Equals and implementing IEquatable<>?

I'm a litte bit confused right now. From my understanding the .NET runtime will pick the overloaded method that best suits the given parameter's type. So I would think, that in the snippet below the method Equals(object obj) will never be called…
markus
  • 177
  • 1
  • 13
1
vote
3 answers

While within a switch block

I've seen the following code, taken from the libb64 project. I'm trying to understand what is the purpose of the while loop within the switch block - switch (state_in->step) { while (1) { case step_a: do { …
rkellerm
  • 5,362
  • 8
  • 58
  • 95
1
vote
1 answer

Reaching code after loop java

I have a chunk of code from a simple chat application, but that is not the important part of this question. It is the part of code which, as it seems to me, should be unreachable: while (!end) { …
dzenesiz
  • 1,388
  • 4
  • 27
  • 58
1
vote
4 answers

Unreachable code in scala?

For some reason the following code is unreachable. I cannot understand why my code will never get reached as this is a simple pattern matching. Here it is: type Occurrences = List[(Char, Int)] def combinations(occurrences: Occurrences):…
Bula
  • 2,398
  • 5
  • 28
  • 54
1
vote
2 answers

Unreachable code C#

Doing a few c# loops and if statements. Getting a highlight for unreachable code on a for loop. I can't quite figure this 1 out. public bool checkTime() { // Read values back from Json file var serializedList =…
JARRRRG
  • 917
  • 2
  • 14
  • 44
1
vote
3 answers

Unreacheable Catch Block Issue

Setup So I have two exceptions: ProfileException extends Exception UserException extends Exception One of my helper class method throws these two exceptions togeather: Long getSomething() throes ProfileException, UserException I invoke this…
Ace
  • 1,501
  • 4
  • 30
  • 49
1
vote
4 answers

How this if condition is unreachable?

IsSaveNew is type of bool? CoverLetterId is type of int? if (coverLetter.IsSaveNew ?? true || coverLetter.CoverLetterId == null) coverLetter.CoverLetterId == null. This statement is marked as unreachable in visual studio(2012). But if IsSaveNew was…
Subin Jacob
  • 4,692
  • 10
  • 37
  • 69
1
vote
2 answers

Compilation issue: Unreachable statement

Good evening all, I am running into a compilation issue with some code for an introductory java class. The application at hand creates a calculator. When trying to compile, I am receiving an error stating that I have an "unreachable statement",…
1
vote
2 answers

Unreachable code Processing arduino communication

I am trying to provide a communication method using Arduino/Wiring to make two objects move with two joysticks. This is the method that I use for the communication: public PVector serialEvent(Serial myPort) { PVector direction = new PVector(0,…
user2321978
  • 49
  • 1
  • 3