I have to admit I am not sure I see the need for these functions. On current compilers CCTK_Abort is already declared to have the noreturn attribute so the optimizer knows that it does not have to optimize the code branch that leads to it. In addition CCTK_Abort performs useful cleanup (it call MPI_Abort and can be overloaded by the driver which is not the case when calling a trap.
Maybe the better comparison is really to assert(0) instead? In this case the advantage of the trap is that it cannot be made a no-op by defining NDEBUG.
So I would only want to advertise using the trap for debugging and not in place of CCTK_Abort which provides a fairly "clean" abort route.
I have to admit I am not sure I see the need for these functions. On current compilers
CCTK_Abort
is already declared to have thenoreturn
attribute so the optimizer knows that it does not have to optimize the code branch that leads to it. In additionCCTK_Abort
performs useful cleanup (it callMPI_Abort
and can be overloaded by the driver which is not the case when calling a trap.Maybe the better comparison is really to
assert(0)
instead? In this case the advantage of the trap is that it cannot be made a no-op by definingNDEBUG
.So I would only want to advertise using the trap for debugging and not in place of
CCTK_Abort
which provides a fairly "clean" abort route.