I thought those terms where synonymous, but a note in MISRA regarding dead code indicates this to be wrong? What's the difference? Is one a subset of the other?
相关问题
- How do I create a module in MISRAC:2012 that follo
- Are x86 Assembly Mnemonic standarized?
- Are C preprocessor statements a part of the C lang
- Default argument and parameter promotions in C
- What if an object passed into std::swap throws an
相关文章
- Is there a standard way to store XY data in python
- What is the longest possible email address? [dupli
- MISRA C++-2008 Rule 5-0-15 - Array indexing shall
- W3C document states
- C++ new int[0] — will it allocate memory?
- How to compute standard error for predicted data i
- C++: Calculate number of possible floating-point v
- operator new with empty exception-specification ca
Dead code - code that is executed but redundant, either the results were never used or adds nothing to the rest of the program. Wastes CPU performance.
Unreachable code - code that will never be reached regardless of logic flow. Difference is it's not executed.
unreachable code is something that would never be executed because there is no flow control to reach the code.
A dead code is something that gets (or might get) executed, but its results are never used.
Unreachable code
The code to which control flow never enters during the execution of the program. That is unreachable code is that code that is never executed during the course of execution of the program.
Dead code
The code that has no effect on the codes following it no matter how the control flow flows through the program. That is dead code is that code, that doesn't need to be executed during the course of execution of the program, or in other terms, is useless.
So, in true terms none of them is a subset of another. But both unreachable code and dead code are usually removed by the compiler during compilation process as a part of code optimization.
Dead Code
Code that performs functions that have no effect. Basically stuff that wouldn't make a difference if removed.
Unreachable Code
Code that due to other logic will never be executed. This is usually the sign of an error.