dead-code

Will my compiler ignore useless code?

大兔子大兔子 提交于 2021-02-06 09:36:26
问题 I've been through a few questions over the network about this subject but I didn't find any answer for my question, or it's for another language or it doesn't answer totally (dead code is not useless code) so here's my question: Is (explicit or not) useless code ignored by the compiler? For example, in this code: double[] TestRunTime = SomeFunctionThatReturnDoubles; // A bit of code skipped int i = 0; for (int j = 0; j < TestRunTime.Length; j++) { } double prevSpec_OilCons = 0; will the for

javac code elimination capabilities

混江龙づ霸主 提交于 2020-01-20 05:59:44
问题 I'm having a hard time finding information about javac 's code elimination capabilities: I read that if you have something like the following, the if -statement will be eliminated: static final boolean DEBUG = false; if (DEBUG) System.out.println("Hello World!"); // will be removed But how about this, for example: static final int VALUE = 3; if (VALUE > 9) System.out.println("VALUE > 9 ???"); // will this be removed? Or this: static final SomeEnum VALUE = SomeEnum.FOO; if (VALUE==SomeEnum.BAR

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

大憨熊 提交于 2019-12-23 04:53:18
问题 I'm working on a website which is quite a mess. In the <head> 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 always clear namespaces and using a capable Python editor (such as Pycharm) clearly highlights unused imports. I'm looking for something similar in html/javascript. I can of course start writing a comprehensive set of UI-tests (which I should do

Java Compiler: Stop complaining about dead code

ぃ、小莉子 提交于 2019-12-22 04:32:21
问题 For testing purposes, I often start typing some code in an already existing project. So, my code I want to test comes before all the other code, like this: public static void main(String[] args) { char a = '%'; System.out.println((int)a); // To know where '%' is located in the ASCII table. // But, of course, I don't want to start the whole project, so: return; // The real project starts here... } But the compiler complains about the return -statement, because of the following "dead code".

Java Compiler: Stop complaining about dead code

匆匆过客 提交于 2019-12-22 04:32:07
问题 For testing purposes, I often start typing some code in an already existing project. So, my code I want to test comes before all the other code, like this: public static void main(String[] args) { char a = '%'; System.out.println((int)a); // To know where '%' is located in the ASCII table. // But, of course, I don't want to start the whole project, so: return; // The real project starts here... } But the compiler complains about the return -statement, because of the following "dead code".

Is it bad to enable Dead Code Stripping?

*爱你&永不变心* 提交于 2019-12-21 16:48:32
问题 My iOS project uses dlsym to dynamically point to an optional C library. Optional as-in the project can run with our without it, it just adds features. For background info: Detect and use optional external C library at runtime in Objective-C The problem is, XCode cleans up libraries that are "not used". Using dlsym means there are no direct references to my 3rd party library and XCode removes it. I thought I found a solution, in "Other Linker Flags" I added -force_load "$(SRCROOT)/my_external

static variable initialisation code never gets called

拟墨画扇 提交于 2019-12-18 09:24:45
问题 I've got an application that's using a static library I made. One .cpp file in the library has a static variable declaration, whose ctor calls a function on a singleton that does something- e.g. adds a string. Now when I use that library from the application, my singleton doesn't seem to contain any traces of the string that was supposed to be added. I'm definitely missing something but I don't know what.. 回答1: If you have an object in a static library that is not EXPLICITLY used in the

if(false) vs. while(false): unreachable code vs. dead code

心不动则不痛 提交于 2019-12-17 03:42:12
问题 I tried the following in Eclipse: if (false) {} : warning 'dead code' while (false) {} : compilation error 'unreachable code' I was wondering whether there is a real 'reason' for this difference. I already found this... Unreachable code compiler error ...but why not allow while (false) for the same debugging purpose? 回答1: The JLS section on unreachable code explains the rationale. Essentially, Java normally shouldn't use conditional compilation like C routinely does with #ifdef , but there

What is AST,CFG,CLANG, how can we use it in deadcode removal algorithm? [closed]

六眼飞鱼酱① 提交于 2019-12-12 03:21:40
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . I am about to write a dead-code removal algorithm using C language for an online event with our team. The requirements are..... To read a C program source file,Which has many forms of dead-codes. And our output

ClosureCompiler removing dead code with advanced optimizations

為{幸葍}努か 提交于 2019-12-11 12:06:38
问题 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) { alert('Hello, ' + name); } hello.a = 5; hello('New user'); })(); is compiled to: function a(b){alert("Hello, "+b)}a.a=5;a("New user"); Why it cannot ignore the hello.a = 5 ? (It cannot be used outside the context, there is no eval , no [] and no new