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
19
votes
6 answers

How can you tell if a PL/SQL Package, Procedure, or Function is being used?

How can you tell if a PL/SQL Package, Procedure, or Function is being used? Is there an Oracle table or view that contains statistics on PL/SQL Package, Procedure, or Function usage?
plsql_4_life
  • 199
  • 1
  • 1
  • 3
19
votes
8 answers

Quick and easy way to remove "dead" (commented out) code

I'm working with an inherited code base which contains thousands of lines of commented out code. I know the previous coder meant to save all his hard work for posterity rather than simply deleting it but: I will never read it and it just gets in the…
Paul Sasik
  • 79,492
  • 20
  • 149
  • 189
16
votes
1 answer

Is it dead code in LinkedHashMap in JDK11?

I am reading LinkedHashMap source code in JDK 11 and I found a piece of dead code(I'm not sure) As we all know, LinkedHashMap use a doubly linked list to preserve the order of all the elements.It has a member called accessOrder final boolean…
DamonChiu
  • 193
  • 3
13
votes
8 answers

Finding unused (aka "dead") code in Delphi

Are there any tools that can determine if a function/procedure/method/entire class is used? I've seen tools that can help a knowledgeable developer track down unused fragments of code (most are for languages other than Delphi) but most have a steep…
Kenneth Cochran
  • 11,954
  • 3
  • 52
  • 117
13
votes
1 answer

Find Dead Rails Code

What is a good way to find methods in a that are not being called anymore? I'm in the process of refactoring a large Rails application and the worst thing you can find is code that is not being used anymore.
Ibrahim Muhammad
  • 2,808
  • 4
  • 29
  • 39
12
votes
2 answers

How can I detect dead code in an enterprise Java project (Java + JSP + Javascript)?

Does anyone know of a tool for detecting dead code in a Java EE project? I've looked into lots of tools that do this well for pure Java projects, but nothing seems to really handle projects which include JSPs and Javascript files as well. For…
Phil
  • 121
  • 3
12
votes
3 answers

Automated Dead code detection in native C++ application on Windows?

Background I have an application written in native C++ over the course of several years that is around 60 KLOC. There are many many functions and classes that are dead (probably 10-15% like the similar Unix based question below asked). We recently…
Zach Burlingame
  • 13,476
  • 14
  • 56
  • 65
12
votes
2 answers

Java constant expressions and code elimination

As discussed here, javac and other Java compilers may provide code elimination capabilities for if-statements where the condition is a "Constant Expression". How is this affected if my code uses a constant expression that depends on other constant…
11
votes
4 answers

Detect dead code in C#

How can I detect dead code in my C# application?
santosh singh
  • 27,666
  • 26
  • 83
  • 129
11
votes
1 answer

C++ virtual functions: Can the linker remove entries in the virtual function table which aren't called?

This question is a kind of followup to eliminate unused virtual functions, which does not go deep enough for my interest. The problem: When defining classes that have virtual functions, the compiler allocates storage for the virtual function table,…
sh-
  • 941
  • 6
  • 13
10
votes
2 answers

Remove dead code when linking static library into dynamic library

Suppose I have the following files: libmy_static_lib.c: #include void func1(void){ printf("func1() called from a static library\n"); } void unused_func1(void){ printf("printing from the unused function1\n"); } void…
J. Lui
  • 105
  • 1
  • 8
10
votes
3 answers

Java: Dead code elimination

I'd like to know how Java would handle the following scenario: Suppose I have a class called Debug, which looks like this: public class Debug { private static final boolean isAssertEnabled = true; public static void assertTrue(boolean b,…
ykrasik
  • 205
  • 3
  • 8
10
votes
2 answers

Using GCC to find unreachable functions ("dead code")

I was looking for a way of finding statically unreachable functions in a (very) big C++ project. I had tried using doxygen and other static analysis tools suggested here but it seemed that the project is too complicated for them to handle. Finally i…
stnr
  • 435
  • 4
  • 14
10
votes
2 answers

Dead code and/or how to generate a cross reference from Haskell source

I've got some unused functionality in my codebase, but it's hard to identify. The code has evolved over the last year as I explore its problem space and possible solutions. What I'm needing to do is find that unused code so I can get rid of it. I'm…
hutch
  • 326
  • 1
  • 8
9
votes
1 answer

Eclipse marks lines as dead code

I have this function with some dead code, marked by Eclipse. I have two lines that check a & b. Lines that check b are marked as null. public int[] runThis(List buildIds, List scenarios, boolean oflag) { int rating[] = new…
jn1kk
  • 5,012
  • 2
  • 45
  • 72
1
2
3
15 16