# PetscUnreachable
Indicate to the compiler that a code-path is logically unreachable 
## Synopsis
```
#include <petscmacros.h>
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
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscmacros.h.html#PetscUnreachable">include/petscmacros.h</A>


---
[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](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
