...
Code Block | ||
---|---|---|
| ||
int string_loop(char *str) { size_t i; size_t len = strlen(str); for (i=0; i < len; i++) { /* ... */ if (str[i+1] == '\0') /* This code is now reached */ } return 0; } |
Exceptions
MSC00MSC07-EX1 In some situations, dead code may make software more robust against future changes. An example of this is adding a default case to a switch statement even when all possible switch labels are specified (see MSC01-A. Strive for logical completeness for an illustration of this example). Another example is temporarily removing code that may be needed later (see MSC04-A. Use comments consistently and in a readable fashion for an illustration).
Risk Assessment
The presence of dead code may indicate logic errors that can lead to unintended program behavior. The ways in which dead code can be introduced in to a program and the effort required to remove it can be complex. Given this, resolving dead code can be an in-depth process requiring significant changes.
...