Contents

Reaching of unreachable point

Detects when a program reaches an unreachable point.

Overview

Use this check to detect when control flow reaches an unreachable point in a program you create using __builtin_unreachable, which may cause abrupt program termination. Available in Xcode 9 and later.

Executing unreachable code in C

If the switch statement fails to handle a value that a function returns, the program reaches __builtin_unreachable().

switch (value_returning_function()) {
case ...:                  // Warning: if the cases are not exhaustive
default:                   // __builtin_unreachable may be reached
    __builtin_unreachable();
}

Solution

Ensure that switch statements and other control flow statements are exhaustive.

See Also

Undefined Behavior Sanitizer