Unreachable Statements

The Unreachable Statements report shows lines in function definitions that are not reachable in control flow. The existence of such unreachable statements might indicate that some logic is faulty or missing. Consider the following example:

#define TRUE 1
#define TEST TRUE

void funcA () {
    int condition1, condition2;
    if (TEST) {
    } else {
    while (condition1) {
        if (condition2)
        else continue;

Statements are identified as unreachable in the following cases:

  • A condition statically evaluates to true or false and there is code in the other branch
  • Any code occurs after control transfers such as goto, break or continue
The example above has an instance of each case. The resulting report lists each of the two statements as unreachable.

Unreachable Statements

        Analyze Pointer Expressions:                  simple pointer expressions
        Analyze with Task Definitions:                off
        Analyze Union/Bitfield Members Separately:    separate
        Analyze Standard C Library Functions Inline:  on
        Adjust Shared Settings By Previous Analysis:  on

funcA()                                           unreach_stmt.c
          9 not_reached_due_to_condition();

         15 occurs_after_control_transfer();