Questions tagged [dead-code]

Dead code is code in the source code of a program which is executed but whose result is never used or a code that can never be reached or used.

Dead code is code in the source code of a program which is executed but whose result is never used or a code that can never be reached or used.

Dead code is waste of computing power and might result of unexpected behavior to the program.

Examples:

int foo (int a, int b)
{
    int c = a + b;  // dead code - executes and result never used 
    return a - b;
}

void foo ()
{
     bool a = true;
     if (!a)
     {
         // dead code - never called
     }
}
238 questions
0
votes
4 answers

Minimize code in reference to read/write operations

I started with the following code: class Vereinfache2_edit { public static void main(String[] args) { int c1 = Integer.parseInt(args[0]); int c2 = Integer.parseInt(args[1]); int c3 = Integer.parseInt(args[2]); …
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
0
votes
1 answer

Is there something like profile-guided dead code removal?

When building applications, especially when using static linking and having a lot of dependences, I often feel that most of this 50-megabyte executable is just unused bloat, especially if consider only the mode I want. Is there something that lets…
Vi.
  • 37,014
  • 18
  • 93
  • 148
0
votes
1 answer

Dead Code error

I'm getting a dead code error in this Java code snippet, using Eclipse: public void rebirthAction() { Player p = new Player(null); Equipment e = new Equipment(); Skills s = new Skills(null); if ((Equipment.SLOT_SHIELD == -1) &&…
homophobia
  • 11
  • 3
0
votes
2 answers

Difference between *f and (*f) in C?

CppCheck (v1.72) says there is a difference when using (*f) or just *f. The this case void test(float *f) { float a = 0.0f; if(*f>a) { (*f) += 0.01f; if(*f
floquet22
  • 323
  • 2
  • 15
0
votes
1 answer

Is this dead code, redundant code or usefull code?

Let's say you have an application in which module A provides the service SRVA. You also have modules B and C that use SRVA according to the spec. Finally you have modules D and E that shouldn't use SRVA according to the spec. Then you have 2 modes…
Plouff
  • 3,290
  • 2
  • 27
  • 45
0
votes
1 answer

Scan-build cannot find dead code in cygwin environment

Following the tutorial here : http://clang-analyzer.llvm.org/scan-build.html and I write a toy example to check whether scan-build can help find the dead code. The following is the testing code: #include int main () { printf("haha this…
Anakin Tung
  • 419
  • 5
  • 17
0
votes
0 answers

How to know if javascript lib is still used in a website?

I'm working on a website which is quite a mess. In the of the website about a zillion javascript libraries are loaded and I think many of them are not used anymore. The problem is that I'm not sure. In Python (my language of choice) there are…
kramer65
  • 50,427
  • 120
  • 308
  • 488
0
votes
2 answers

Java stopping code execution?

I have a small chunk of code here, and it's called when somebody switches channels in TeamSpeak. The clid is the user's ID, and the cid is the channel ID. Integers lobby and verified are preset IDs representing the 'Tournament Lobby' and 'Name…
Michael Shift
  • 104
  • 2
  • 8
0
votes
2 answers

How does the compiler in Java decide on unreachable code?

How does a compiler decide on with unreachable code? consider these public class Test15 { public static final boolean verdict = false; public static final int verdictInt = 2; public static void main(String[] args) throws IOException…
Droidekas
  • 3,464
  • 2
  • 26
  • 40
0
votes
3 answers

Trouble Converting a String to Acronyms

I'm working on a method which gets as an input an array of Strings and returns an array of its Acronyms that are only capital letters. For example: [United Nations, United Federation of Planets, null, , ignore me] -> [UN, UFP, null, , ] For some…
Tam211
  • 723
  • 5
  • 10
  • 27
0
votes
2 answers

Why isn't "int someVal=0" for an instance field considered dead code?

Why do I get no dead code warning for the initialisation of someVal here? public class DeadCode { private int someVal = 0; public DeadCode(int someVal) { this.someVal = someVal; } public int getSomeVal() { return…
0
votes
5 answers

Why does Eclipse tell me that this is dead code?

I'm trying to create a recall program that sends text messages to 200+ people and then searches an email that the replies are forwarded too. This method is supposed to search the array list of replies that is built using another method, but it…
user3080303
0
votes
1 answer

Why is this code segment marked dead code?

For the life of me, I can't see why Eclipse is marking the else if clause below as "dead code": BaType rbName = rSoapXml.getName().getBName(); BaType cbName = cSoapXml.getName().getBName(); IaType riName = rSoapXml.getName().getIName(); IaType…
Withheld
  • 4,603
  • 10
  • 45
  • 76
0
votes
1 answer

How to really find all unused css styles on a website

For refactoring purposes, I am trying to find all unused css style definitions on my website. After googling a while I found various tools like Google Chrome's Audit feature or the Firefox add-on called "dust-me selectors": How can I find unused…
Timo Ernst
  • 15,243
  • 23
  • 104
  • 165
0
votes
0 answers

How does ADT optimize dead code for Android apps?

I'm developing a set of libraries for my Android apps. But, as they grow in features, I don't want unused features & 3rd party libraries included in the various APKs. Does the Android compiler automatically exclude classes and libraries that are…
MCLLC
  • 496
  • 4
  • 12