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

Global getting dead-strippped in Xcode in spite of __attribute__((used))

I am building an Xcode static library project, where I have a class defined as: class New { public: New() { // Do something }; static New fNew; }; __attribute__((used)) New New::fNew; The static global fNew should not be…
AbhinavChoudhury
  • 1,167
  • 1
  • 18
  • 38
2
votes
2 answers

Conditional statement:dead code

I'm working on a JavaEE application and I have the following method: public String alterar_data_ato_med (int cod_ato, GregorianCalendar nova_data) { AtoMedico a=em.find(AtoMedico.class,cod_ato); Medico m=a.getmedico(); Utente…
Ghost
  • 113
  • 4
  • 11
2
votes
2 answers

Correct Version control of dead ends

Problem When developing experimental code, I sometimes commit changes which lead to a dead end. Then I'd like to rollback to some previous revision, to start over. But I don't know how to do it best. Example - Problem Lets say we have the following…
Waog
  • 7,127
  • 5
  • 25
  • 37
2
votes
3 answers

How to prevent compiler from optimizing a load to variable that is never used

Intro: Im trying to quick hack fix old code and use __try MSVC extension to check if some ptr points to some legit memory or if *ptr will cause memory violation(if so I drop processing of this ptr). So I wrote something like: bool…
NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277
2
votes
1 answer

How to make closure compiler to remove all dead code with advanced optimization in larger projects?

The following code: function f(a) { a.a = 5; return a; } f(function() {}); f(function() {}); f(function() {}); f(function() {}); f(function() {}); f(function() {}); f(function() {}); f(function() {}); f(function() {}); f(function() {}); f(function()…
TN.
  • 18,874
  • 30
  • 99
  • 157
2
votes
2 answers

ClosureCompiler removing dead code with advanced optimizations

The following code: (function() { var hello = function(name) { alert('Hello, ' + name); } hello('New user'); })(); with ADVANCED_OPTIMIZATIONS is compiled to: alert("Hello, New user"); But this code: (function() { var hello = function(name)…
TN.
  • 18,874
  • 30
  • 99
  • 157
2
votes
0 answers

VS C++ Dead code elimination

I have a small project in C++ VS 2010, which uses a couple of static link libraries(.lib files). This options are turned on: OPT:REF, OPT:ICF, /GL, GR- When I add unused method to a class, which uses some code from static libraries, compiler…
let4be
  • 1,048
  • 11
  • 30
2
votes
5 answers

C++ - What's the proper way to perform a speed test?

I searched many questions which asked related information, but the answers didn't quiet match exactly what I wanted for an answer. I'll try to explain the issue as best I can. Basically when running the code in release mode the compiler seems to…
2
votes
2 answers

Dynamic dead code elimination tools for complex C++ projects

We have a project with a lot of code, part of it is legacy. As part of the work flow, every once in a while, all the functionality of the product is checked. I wonder if there is a way to use this fact to dynamically check which parts of the code…
borod108
  • 766
  • 1
  • 6
  • 16
2
votes
2 answers

Identifying Unused Functions in C/C++

Possible Duplicate: Finding “dead code” in a large C++ legacy application My project has a lots of C source files each with a lots of global functions. Many of these are no longer referenced by any caller at all. Is there a simple way to…
JavaMan
  • 4,954
  • 4
  • 41
  • 69
1
vote
1 answer

VFY: dead code error in modified Sony Ericsson Launcher

I am in the process of making the corner circles work on hdpi devices. Everything works except pressing the "add" button (long pressing screen as well), and pressing the sorting style button in the app drawer. Both result in a F/c of the launcher.…
user994079
  • 11
  • 2
1
vote
2 answers

Unable to evaluate functions in Go debugging using delve

I'm on an M1 Mac (ARM64 chip) and still unable to invoke functions via the debugger in VSCode which is using the DLV backend. Debug Console call test() Unable to evaluate expression: could not find symbol value for test test() Unable to evaluate…
user38643
  • 341
  • 1
  • 7
1
vote
0 answers

Why a basic unreferenced c++ function does not get optimized away?

Consider this simple code: #include extern "C" { void p4nenc256v32(); void p4ndec256v32(); } void bigFunctionTest() { p4nenc256v32(); p4ndec256v32(); } int main() { printf("hello\n"); } Code size of those…
Pavel P
  • 15,789
  • 11
  • 79
  • 128
1
vote
1 answer

List all python functions within a vscode workspace that are uncalled?

Context Since I have a workspace with multiple python/github repositories, vulture does not return all dead Python code. So to find all uncalled functions, I use the following steps: Search all functions, with: CTRL+SHIFT+F, Alt+R, ^(\s*)(def…
a.t.
  • 2,002
  • 3
  • 26
  • 66
1
vote
1 answer

Add ts-prune to lint-staged

I'd like to run ts-prune in order to detect dead code on the files staged for commit using lint-staged. I've tried the following: "find-deadcode": "ts-prune -e", ... "lint-staged": { "*.{js,ts,tsx}": [ "npm run find-deadcode", "eslint…
rfc1484
  • 9,441
  • 16
  • 72
  • 123