Graphviz 12.0.1~dev.20240715.2254
Loading...
Searching...
No Matches
unreachable.h File Reference
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for unreachable.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define UNREACHABLE()
 

Macro Definition Documentation

◆ UNREACHABLE

#define UNREACHABLE ( )
Value:
do { \
fprintf(stderr, "%s:%d: claimed unreachable code was reached\n", __FILE__, \
__LINE__); \
abort(); \
} while (0)

Marker for a point in code which execution can never reach.

As a C11 function, this could be thought of as:

_Noreturn void UNREACHABLE(void);

This can be used to explain that a switch is exhaustive:

switch (…) { default: UNREACHABLE(); …remaining cases that cover all possibilities… }

or that a function coda can be omitted:

int foo(void) { while (always_true()) { } UNREACHABLE(); }

Definition at line 30 of file unreachable.h.