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.
Questions tagged [unreachable-code]
181 questions
0
votes
1 answer
Hiding an element in the layout on Activity Result
I'm trying to hide a textView in my layout after I receive a result from an activity. I have a variable declaration - View lblEmptyList, which I instantiate in the onCreate:
lblEmptyList = findViewById(R.id.emptyList);
I tried this:
protected void…

Igal
- 5,833
- 20
- 74
- 132
0
votes
3 answers
gcc reports "will never be executed" about the line: while(fgets(line, MAX_LINE, stdin) != NULL)
I'm looking for an explanation why gcc are giving this warning for me.
I'm compiling with the gcc-3 on cygwin with the -Wunreachable-code flag, and the gcc says this warning for me:
main.c:223: warning: will never be executed
That's this line:…

Jack
- 16,276
- 55
- 159
- 284
-1
votes
1 answer
Why are these lines of my javascript code unreachable according to VSCode?
I'd like to ask why lines 46 - 49 are unreachable in my discord.js script. I really don't know why it happened.
const TOKEN = "hidden"
const client = new Discord.Client({
intents: [
"GUILDS",
"GUILD_MESSAGES"
…

Malexz
- 1
-1
votes
1 answer
part of my code is unreachable in vscode, Iam trying to build basic rock paper scissors game
I am working on rock paper scissors game in order to learn python but my code is being greyed out/unnreachable, how would you solve it?
import random
def play():
user = input("What is your choice'r' for rock, 'p' for paper, 's' for…

Rick Dzurek
- 1
- 2
-1
votes
2 answers
"unreachable code" after select statement in a Go program
I am playing with channels and don't quite understand why the code I wrote becomes unreachable at this point and also a deadlock arises. Shouldn't the select take the value from the quit channel and then exit from the infinite for loop?
func…

unknownerror
- 39
- 8
-1
votes
3 answers
Why does it say that my return statement is "unreachable"
i was working on a very simple minecraft plugin for a school project and i can't seem to get this return false; to be "reached"
im using the eclipse IDE, heres my code
package com.genuishour.me;
import org.bukkit.command.Command;
import…
-1
votes
1 answer
New to Python, issues with unreadable code in if/else statements
I am new to programming with Python and have been having non-stop issues with parts of my code being listed as unreachable. Here is my program:
def inputData():
userNumber = int(input("Please enter a number to check if it is divisible by 7…
-1
votes
3 answers
Java error: unreachable statement when create new linked list node
I wrote a program for merge two linkedlist so I create a dummyHead first. But the compiler returns me an error: unreachable statement. I searched it on Internet but still don't understand why is it.
The code is :
/**
* class ListNode {
* public…

Meilan
- 434
- 6
- 17
-1
votes
1 answer
While loop making initial line of code unreachable in python
So I've been trying to make a basic text game in python, and I'm using this code to constantly generate random numbers for use in certain functions to decide if the player is damaged, the player is attacked, etc.:
rng = random.randint(0,100)
…

Ppick
- 13
- 5
-1
votes
1 answer
Java Unreachable code
Why is my code returning this error? I've made any mistake? I can not see my error in this code. Can anybody help me?
The code is bellow:
public static void minMax(int m[][])
{
int menor = 0;
int maior = 0;
int i =…

LGirdwood
- 1
- 1
-1
votes
2 answers
Unreachable code - updating existing row
In the code below db.setTransactionSuccessful(); gives error Unreachable code. Can anyone tell me how to solve this problem please?
public boolean updateDiaryEntry(String title, long rowId)
{
ContentValues newValue = new…

Patrick Liss
- 1
- 3
-1
votes
2 answers
unreachable code at line 104: youTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtubeplayerview);
Unreachable code Home.java /idg/src/com/idg/omv line 104 Java Problem
I'm getting an error stating unreachable code at line 104 which is:
youTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtubeplayerview);
I'm not sure exactly…

user3009687
- 369
- 2
- 7
- 17
-2
votes
1 answer
This code is inaccessible, how do I fix this error?
Programmer friends, I need your help. I was trying to make a Uno using Python but to my despair, an error appeared that I don't know how to fix it.
"This code is unreachable:138"
I would be very grateful, if anyone can help me fix this.
Here is my…
-2
votes
1 answer
Why is an Unreachable code error in this sequence of code and not the latter?
public String motorNoise() {
String[] ignition={"vroom","pop","bang"};
engineNoise=(int)(Math.random()*3);
startEngine=ignition[engineNoise];
if (engineNoise==2)
System.out.println("This car needs a service");
return…

daithi112
- 1
- 1
-2
votes
3 answers
issue in if else statement
I need help to solve this issue that I am having. I have went through few question available in stackoverflow but i still dont get it.
this is the code im writing:
var myFeedback = ""
if (this.userFriendlinessRating <= 4.0 &&…

YOS
- 15
- 5