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
2 answers

document.cookie can't access dead object in firefox 28

This error appeared for me for the first time today. I'm using Firefox 28 which seems to be the most recent version. Here is the code: When it gets to the last line I get the error "Can't access dead object" and the page freezes, won't accept…
slashdottir
  • 7,835
  • 7
  • 55
  • 71
0
votes
2 answers

supress warnings: dead code and conditional compilation

I often declare some constants to conditionally compile/not compile chunks of code. I put these constants on one class, then I use them all along the (big) app code. Conf.java public static final int GUI_ACTIONBAR_HEIGHT=0; elsewhere…
rupps
  • 9,712
  • 4
  • 55
  • 95
0
votes
3 answers

Dead Code Error in Java

I have an array of objects. I want scan it and as long as the object I find is not null, increase a counter by 1. When I find the first null object, I want to jumb out of the for loop since there is no reason to continue looping. I wrote the…
PeterHiggs
  • 97
  • 2
  • 10
0
votes
2 answers

Dead code in Java/Android

is there a way to tell the compiler in Java or Android to not remove some statements in code -which are intended to clean up variables after use to prevent any data remnant in ram-?? would creating a dummy method solve this issue?? these statements…
Jana
  • 63
  • 8
0
votes
5 answers

Java Dead Code, can someone explain?

This is part of a binary tree class, here is the find function, given the key to find the node in the tree, if not found return null, however this part have been recognized as dead code, when I move the if(current==null) statement to the bottom of…
albert
  • 15
  • 4
0
votes
1 answer

How to Identify any redundant code C#

I have been given this task: Identify any redundant code in the classes. Explain in detail why the code is redundant. I am working with a large scale c# application with dozens of classes, can anyone recommend where to begin or how best to approach…
brian4342
  • 1,265
  • 8
  • 33
  • 69
0
votes
2 answers

Can anyone please explain this "dead code" example?

Some explaination about the following snippets: I'm messing with some Bluetooth discovery calls. For that I'm using a callback, which will be invoked if a BluetoothDevice is found or not. If no device was found the parameter is…
Steve Benett
  • 12,843
  • 7
  • 59
  • 79
0
votes
1 answer

How to clean up dead/useless code

The project(written in Java) is getting large and large and some code will never be used. Is there a way to detect those dead/unuseful code and clean them up. I'm open for ideas.
Edmond
  • 614
  • 2
  • 11
  • 26
0
votes
3 answers

Change C code to run fully (including all sections of if)

NOTE: I realise my question was not clear. I have modified it now, and apologise for making the mistake in the first place. I have a large C project that is to be run on an embedded system. I use the ARM compiler. The code is spread across multiple…
tdk
  • 342
  • 1
  • 13
0
votes
2 answers

Unreachable Code at return START_STICKY;

I have an app I'm building however I've come across an error stating "Unreachable Code" after the line return START_STICKY; starting with if (Config.DEVELOPMENT) { and I'm not sure how this can be resolved so my source executes correctly. SOURCE…
user2533377
  • 45
  • 1
  • 2
  • 6
0
votes
1 answer

I need a way to remove "dead pages" from an ASP.NET 2.0-4.0 site

I've taken over about 30 projects at a company. Through the years the guy who ran things worked directly on the server. There's tons of dead pages that cause Visual Studio to break. I have JetBrains Resharper (Latest) and I also have Telerik Full…
TooMuchToLearn
  • 173
  • 1
  • 3
  • 10
0
votes
2 answers

Value Stored to 'valid' is never read

I have a validation method by which I analyse whether a particular variable passes a validation criteria. Here's the code: -(BOOL)validateFields{ BOOL valid = FALSE; if (dateEntry != TRUE && saveOrderType != TRUE) { if…
Dan Hanly
  • 7,829
  • 13
  • 73
  • 134
0
votes
2 answers

How to better initialize strings to avoid dead stores

I found a few questions like this but I couldn't find this particular question. I have a number of strings that are initialized as NSString *string = [[NSString alloc] init]; which are then assigned a value depending on the results of an if/else…
ele
  • 6,021
  • 5
  • 25
  • 35
0
votes
1 answer

Gcc dead code removal with specific functions used

Lets say I have a large library liblarge, and application app which links to liblarge. Liblarge is under the LGPL license, and app is under a proprietary one. I'd like to be able to remove all "dead code" from liblarge which is not used from app.…
joe
  • 1,125
  • 9
  • 18
0
votes
1 answer

Methods for selectively compiling a framework C++?

I would like to selectively compile part of an (extremely bloated and large) framework only as the elements are used. I've had a few ideas on how I can do this, but failed to implement either properly; Use a define macro with the same name as a…
kvanbere
  • 3,289
  • 3
  • 27
  • 52
1 2 3
15
16