VTK-m  2.0
Macros
Unreachable.h File Reference

Go to the source code of this file.

Macros

#define VTKM_UNREACHABLE(msg)
 VTKM_UNREACHABLE is similar to VTK_ASSUME, with the significant difference that it is not conditional. More...
 
#define VTKM_UNREACHABLE_IMPL()   (void)0
 
#define VTKM_UNREACHABLE_PRINT(msg)
 
#define VTKM_UNREACHABLE_ABORT()   abort()
 

Macro Definition Documentation

◆ VTKM_UNREACHABLE

#define VTKM_UNREACHABLE (   msg)
Value:
VTKM_SWALLOW_SEMICOLON_PRE_BLOCK \
{ \
VTKM_UNREACHABLE_IMPL(); \
VTKM_UNREACHABLE_PRINT(msg); \
VTKM_UNREACHABLE_ABORT(); \
} \
VTKM_SWALLOW_SEMICOLON_POST_BLOCK

VTKM_UNREACHABLE is similar to VTK_ASSUME, with the significant difference that it is not conditional.

Control should never reach a path containing a VTKM_UNREACHABLE statement under any circumstances.

If assertions are enabled (e.g. neither NDEBUG nor VTKM_NO_ASSERT is defined), the following steps are taken:

  1. Print an error message containing the macro argument and location of the VTKM_UNREACHABLE call.
  2. Abort the kernel (if CUDA) or process.

This allows bad code paths to be identified during development and debugging.

If assertions are disabled and the compiler has some sort of 'unreachable' intrinsic used to provide optimization hints, the intrinsic is used to notify the compiler that this is a dead code path.

◆ VTKM_UNREACHABLE_ABORT

#define VTKM_UNREACHABLE_ABORT ( )    abort()

◆ VTKM_UNREACHABLE_IMPL

#define VTKM_UNREACHABLE_IMPL ( )    (void)0

◆ VTKM_UNREACHABLE_PRINT

#define VTKM_UNREACHABLE_PRINT (   msg)
Value:
std::cerr << "Unreachable location reached: " << msg << "\n" \
<< "Location: " << __FILE__ << ":" << __LINE__ << "\n"