:orphan: # PetscUnreachable Indicate to the compiler that a code-path is logically unreachable ## Synopsis ``` #include void PetscUnreachable(void) ``` ## Notes Indicates to the compiler (usually via some built-in) that a particular code path is always unreachable. Behavior is undefined if this function is ever executed, the user can expect an unceremonious crash. ## Example usage Useful in situations such as switches over enums where not all enumeration values are explicitly covered by the switch ```none typedef enum {RED, GREEN, BLUE} Color; int foo(Color c) { // it is known to programmer (or checked previously) that c is either RED or GREEN // but compiler may not be able to deduce this and/or emit spurious warnings switch (c) { case RED: return bar(); case GREEN: return baz(); default: PetscUnreachable(); // program is ill-formed if executed } } ``` ## See Also `SETERRABORT()`, `PETSCABORT()`, `PETSC_ATTRIBUTE_COLD`, `PetscAssume()` ## Level advanced ## Location include/petscmacros.h --- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscmacros.h) [Index of all Sys routines](index.md) [Table of Contents for all manual pages](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)